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

2015/2/23

I don't see an animation... Everything happens in 1 Frame...

enchino enchino

2015/2/23

#
Hello! I am really confused... My Scenario is like this spider is on one point, under the spider an obstacle and 2 other obstacles right next to the obstacle When I code a little program, (don't be confused I just translated the german codes into english) for example public void act() { while(obstacleRight()) { step(); } } I just see that the Spider is on the place where there isn't any Obstacle under him! That means I don't see the single frames where the spider goes over the obstacles, I just see the last step where the Program ends... Does anyone know what I can do? Thank you :D
davmac davmac

2015/2/23

#
First, use 'code' tags when you post code. Now, the problem is really that computers are fast. Your while-loop above executes very quickly, so you only see the start (before the loop) and the end (after the loop has finished). Everything in between happens too quickly for you to see. One possibility is to insert a delay into the loop; you can use the Greenfoot.delay(...) method for this (look it up in the documentation). However, it's quite possible that you don't really need the while-loop at all. When your scenario runs, the 'act' method for each actor gets called repeatedly anyway, inside an "implicit" loop. It's usual for your actor to take only one "step" each time that act is called. You could do this by chaning the 'while' to an 'if' statement.
enchino enchino

2015/2/24

#
Thank you davmac, thats so logic.. I'm a amateur, thats why i have noobie codes xDD
You need to login to post a reply.