1 decade ago by Dhoombaby
hi,
in my game my player shoots when i click shoot button , but i want the cops i.e enemy to fire when player is near to him but only in that direction ....my enemy is moving from left to right...so when player is on left side of him he should fire left..when player is right side of him he should fire right side...and only 3-4 bullets should come out...
i have applied logic..
if(this.distanceTo(ig.game.player) < 200 )
{
ig.game.spawnEntity( EntityBullet1, this.pos.x, this.pos.y+40, {flip:this.flip});
}
here problem i am facing is that when player is near to him he fires bullet but bullets comes out continuously till it kills player and and bullet fire only in one direction...so what is solution to this problem ?? i have stuck to it badly...can anyone help me?? reply urgently...
Thanks..
in my game my player shoots when i click shoot button , but i want the cops i.e enemy to fire when player is near to him but only in that direction ....my enemy is moving from left to right...so when player is on left side of him he should fire left..when player is right side of him he should fire right side...and only 3-4 bullets should come out...
i have applied logic..
if(this.distanceTo(ig.game.player) < 200 )
{
ig.game.spawnEntity( EntityBullet1, this.pos.x, this.pos.y+40, {flip:this.flip});
}
here problem i am facing is that when player is near to him he fires bullet but bullets comes out continuously till it kills player and and bullet fire only in one direction...so what is solution to this problem ?? i have stuck to it badly...can anyone help me?? reply urgently...
Thanks..