I have a girl who must be moved when the "space" bar is press (the die is stopped at a random number between 1 and 6) and I wrote all the code and it has the syntax right, but the girl doesn't move and I don't know why.
nr = Die.x;
while(isTouching(Start.class)||isTouching(Box_2.class)||isTouching(Box_4.class)||isTouching(Box_6.class)||isTouching(Box_8.class))
{
if( nr%2 == 1)
{
getWorld().removeObjects(getWorld().getObjects(Personaj.class));
getWorld().addObject( new Personaj (), 50, 590);
}
else
{
move_1();
}
nr = Die.x;
}
public void move_1()
{
if(isTouching(Start.class))
{
getWorld().removeObjects(getWorld().getObjects(Personaj.class));
getWorld().addObject( new Personaj (), 480, 580);
}
if(isTouching(Box_2.class))
{
getWorld().removeObjects(getWorld().getObjects(Personaj.class));
getWorld().addObject( new Personaj (), 880, 580);
}
if(isTouching(Box_4.class))
{
getWorld().removeObjects(getWorld().getObjects(Personaj.class));
getWorld().addObject( new Personaj (), 1050, 450);
}
if(isTouching(Box_6.class))
{
getWorld().removeObjects(getWorld().getObjects(Personaj.class));
getWorld().addObject( new Personaj (), 680, 450);
}
if(isTouching(Box_8.class))
{
getWorld().removeObjects(getWorld().getObjects(Personaj.class));
getWorld().addObject( new Personaj (), 290, 450);
}
}
the girl should move from 0 to 2, for exemple, or 2 to 4 if the number is even, and move back to 0 if the number is odd. What do I do wrong?
