Hello all! This is a common issue that I have had before and I can’t seem to figure it out. Basically I have a player who shoots on the X axis, and depending on his direction he shoots either left or right. I have that working fine. The issue is, say he is shooting left meaning he is facing left. If he changes to face the right any bullets he has fired left that has not been destroyed yet automatically change direction to the right. I know the solution has to be very simple but I can’t think of it, and the funny part is I have had this issue before and fixed it.
Here is the update on my bullet class:
override public function update():void
{
if (thePlayer.direction == 2)
{
x += 8;
}
if (thePlayer.direction == 1)
{
x -= 8;
}
if (collide("level", x , y))
{
this.destroy();
}
}
And this is my player class where the bullets are fired:
if (Input.pressed(Key.CONTROL))
{
FP.world.add(new theBullet(this.x + 5, this.y + 20));
}
I think I have to do something else in the bullet class but I don’t remember what.
Thanks guys