This forum is read only and just serves as an archive. If you have any questions, please post them on

9 years ago by Dhoombaby

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 enemy is moving from left to 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( < 200 )
{ 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 what is solution to this problem ?? i have stuck to it badly...can anyone help me?? reply urgently...


9 years ago by stillen

You can use a timer to offset the bad guys fire action. Setting up timers were discussed here:

Depending on the where the bad guy is in relation to your player, you can adjust the flip property:

9 years ago by Dhoombaby

Thanks Stillen...But now problem is that the enemy fire in wrong direction..means when player is moving right he fires in opposite question is that how to check the player and enemy are in opposite direction??

9 years ago by Zoneh

If I were you I'd add "facingTo" property to enemies and the player. When you move your entity you should set facingTo to the proper value. Then check the property when shooting.

9 years ago by Dhoombaby

Thanks Zoneh...but can it explore it more....
Page 1 of 1
« first « previous next › last »