View Single Post
  #6  
Old 09-08-2010, 03:41 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by khortez View Post
[PHP]
this.equip = !this.equip;
You're toggling this.equip every time the fire button is pressed. You should only set this.equip to false whenever you want to unequip the weapon, and only set it to true when you want to equip the weapon.

if you want the fire button to also equip a gun the first time it's pressed, then do something like:
PHP Code:
// whenever the fire button is pressed
if (! this.equip) { // the gun isn't equipped yet, so equip it
  
this.equip true;
  
// equip ganis or whatever else you want to do
  
return; // don't do any of the shooting stuff yet
}

// do shooting stuff 
I should probably also add that you might want to use a timeout and keydown() functions instead of onKeyPressed() so that you can handle automatic weapons more efficiently.
__________________
Reply With Quote