Hello,
I'm currently making a Slayin' type game where the background is non-scrolling, and the player/enemies have a static y value.
The enemies currently move left from spawn, but I would like them to change direction when hitting the edge of the world.
I came up with:
The problem is though, once it reaches the end of the world, it's just stuck there because the move(-movespeed) from act is still running. So I tried this:
but probably just made the problem even worse, because now it'll never reach the other end of the world. So I also thought about having something like
but this doesn't work either, because it only works for that set point. Any suggestions on how to alternate the directions?
public void act()
{
move(-movespeed);
if(atWorldEdge() == true)
{
World world;
world = getWorld();
getImage().mirrorHorizontally();
move(movespeed);
}
}public void act()
{
setImage(myGif.getCurrentImage());
if(getX()<580 && getX()>25)
{
move(-movespeed);
countdown --;
}
if(countdown <= 1 && atWorldEdge() == true)
{
respawntime = 0;
World world;
world = getWorld();
getImage().mirrorHorizontally();
move(movespeed);
}
}if (getX() == valueofleftedge)
{
move(movespeed);
}else if(getX() == valueofrightedge)
{
move(-movespeed);
}

