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

4 days ago

how do i add delay to 1 actor?

Fat_moose Fat_moose

4 days ago

#
I am trying to make a healthbar but the healthbar goes down way to fast, i tried the Greenfoot.delay() but then everything slows down. Can someone help me?
danpost danpost

3 days ago

#
Fat_moose wrote...
I am trying to make a healthbar but the healthbar goes down way to fast, i tried the Greenfoot.delay() but then everything slows down. Can someone help me?
The Greenfoot.delay() method will suspend all actions for the number of act cycles given as its parameter. If the touching of another actor causes the healthbar to decrease, then it is probably true that for each act the touching occurs or continues, the healthbar will decrease. My suggestion is to list objects it touches and only decrease the healthbar when an object is added to the list (and not when the object is already on the list). The sequence of checks might be as follows: * create new touching list * remove objects from touch list that are not in new list (removing those no longer touching) * add objects from new list to touch list when not in touch list and perform actions (healthbar, for example) This last step may require the use of instanceof checks to determine the type of objects touched.
You need to login to post a reply.