This site requires JavaScript, please enable it in your browser!
Greenfoot back
CassWin
CassWin wrote ...

2014/2/20

act not working during while

CassWin CassWin

2014/2/20

#
i have a while loop in my code and while the while loop is being executed the act() doesn't run. what to do???? help plzz
CassWin CassWin

2014/2/20

#
the while loop runs for 1 sec.
danpost danpost

2014/2/20

#
Refer to the current discussion called 'Need delay without delaying game'.
CassWin CassWin

2014/2/20

#
its not like tht problem.
CassWin CassWin

2014/2/20

#
sum = 0; jumpStrength = 16; while(jumpStrength >= sum) { setLocation(getX(), getY() - sum); Greenfoot.delay(1); sum= sum+1; } fall(); // after reaching the jumping height ie jumpStrenght, actor falls. im doing a doodle jump game. So there are platforms and platforms keep on moving from the top to bottom. the jumping actor is a frog. when i press space --> "jumping button", the platforms hangs ie it stop moving down till the frog makes the jump ie till the while loop is executed ie the following code in platform stops working. public class platform extends Actor { public void act() { move(2); if(getY() > 580) // height of the world is 600. so once it reaches down the platform is removed. { getWorld().removeObject(this); return; } } }
davmac davmac

2014/2/20

#
its not like tht problem.
It looks to me as though it's exactly that problem. From that discussion:
I used Greenfoot.delay() but this delays the whole game
How is that different from what you have here? You are also using Greenfoot.delay(), and it delays the whole game, not just the one actor.
You need to login to post a reply.