Good afternoon people,
I'm trying to make a shooting system using the keyboard but it's not working properly ... do not fire one at a time
Could you please help me?
Thank you very much.
Here's my code:
var controlKeys =
{
left: "left",
right: "right",
space: "space"
};
if(wade.isKeyDown(controlKeys.left)&&!wade.isKeyDown(controlKeys.right))
{
this.setVelocity(-100,0);
}else if(wade.isKeyDown(controlKeys.right)&&!wade.isKeyDown(controlKeys.left))
{
this.setVelocity(100,0);
} else{
this.setVelocity(0,0);
}
if(wade.isKeyUp(controlKeys.space)){
var tiro = wade.getSceneObject("Tiro").clone();
tiro.setPosition(this.getPosition().x, this.getPosition().y-50);
wade.addSceneObject(tiro);
tiro.moveTo(0, this.getPosition().y,-300);
}