I'm enjoying the keypressing functionality, but now realize that it would be a smoother and less damaging experience for the user if we had to the ability to rapid fire, i.e. (launch missiles continuously from the main player by keeping your finger down on the fire button, one missile coming out every xth of a millisecond). I tried nesting a kepress call inside of registerCallback() like this...
$.playground().registerCallback(function(){ /*when key is pressed down*/ $(document).keydown(function(e){ if(!game.playerHit){ switch(e.keyCode){ case 75: /*adjust and fire player weapon (k)*/ player.fireweapon(); break; } } }); },1000);
but its not firing the missiles smoothly in good timing...any advise would be great!
Instead of using events you should use the key tracker. Just enable it by passing keyTracker: true in the playground options. Then you can simply acces the array $.gQ.keyTracker where the value at the indexes represented by keyCodes is true if the corresponding key is presses.
Then you create a callback that you register with a frequency equal to your firering rate where you check the status of the 'fire' key.