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

2014/2/22

Making actors popup and then disappear for a bit

mnmluv mnmluv

2014/2/22

#
Ok, so, obviously, i am new and need help. I want to know how i can make an actor, like "Apple", pop up on screen for 5, then disappear. apple can be eaten, the world is Grassy, and i am pleading for answers. suggestions?
danpost danpost

2014/2/22

#
You just need to count the act cycles (about 300 of them) between adding and remove the pop-up.
mnmluv mnmluv

2014/2/22

#
danpost wrote...
You just need to count the act cycles (about 300 of them) between adding and remove the pop-up.
OK, like i said, I'm REALLY bad, so do you mind translating that into code? THANK YOU SOOOOOOOO MUCH!
danpost danpost

2014/2/22

#
What code do you have right now, as far as adding and removing the 'pop-ups' (apples).
jimboweb jimboweb

2014/2/22

#
It would be something like this. Up at the start of your class you'd have a line like: int count =0; then inside your act() method, just say something like count++; if(count == 300) { World myWorld = getWorld(); myWorld.removeObject(this); } Play around with the 300 to get it to stay the right amount of time. There are better and more sophisticated ways to do this, but this would be a good simple solution.
mnmluv mnmluv

2014/3/1

#
jimboweb wrote...
It would be something like this. Up at the start of your class you'd have a line like: int count =0; then inside your act() method, just say something like count++; if(count == 300) { World myWorld = getWorld(); myWorld.removeObject(this); } Play around with the 300 to get it to stay the right amount of time. There are better and more sophisticated ways to do this, but this would be a good simple solution.
ohmy----. thank you SOOOOOOO much! I finally figured this out using this. THANKYOUTHANKYOUTHANKYOUTHANKYOU!!!!!
You need to login to post a reply.