Using the example code that came with ImpactJS, I am wondering what
{direction:this.lastPressed}
means. The code below refers to the player entity, when the 'attack' button is pressed.
Is 'direction' a method of some sort? I am guessing from this code, it is telling the projectile which way to travel based on the entity's direction, but I can't figure out how.
//attack
if(ig.input.pressed('attack')) {
if (this.weapon == 'projectile'){
// create a projectile
ig.game.spawnEntity('EntityProjectile',this.pos.x,this.pos.y,{direction:this.lastPressed});
}else{
// we simulate a sword with a very fast moving projectile with a limited range
ig.game.spawnEntity('EntitySword',this.pos.x,this.pos.y,null);
}
ig.game.sortEntitiesDeferred();
}
I decided to go back to basics with this and use the code for this game to base mine on. This is a lot more straight-forward, especially for the first time game developer.