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

2014/3/18

Life Counter

hannah_copeland hannah_copeland

2014/3/18

#
I need to do a life counter for my game and i don't understand how i can make it so when a life is gone an image will go off the screen to represent lives. Help?
sophie_verrier sophie_verrier

2014/3/18

#
Thats nice
danpost danpost

2014/3/18

#
I can think of two ways to go about this: (1) have one actor that will have an int field for lives and an image large enough to hold the maximum number of life images; have its image display the number of life images that the value of the int field holds (2) have multiple life actors whose number of them in the world represents the number of lives; you will have to keep track of them either in an array or by their location I prefer the first way. It is like a basic counter, but with a different kind of display. And keeping track of one absolute actor is much easier than trying to keep track of many possible actors.
hannah_copeland hannah_copeland

2014/3/18

#
The first way sounds much easier and less complicated, but how do you do this?
hannah_copeland hannah_copeland

2014/3/18

#
i've managed to make a life counter but i cant figure out how to make my player come back after a life has gone? '
danpost danpost

2014/3/18

#
This all comes down to (1) how you create your world (2) what is involved in resetting after losing a life (3) possibly other things. If you can get away with just relocating your player instead of removing it from the world, that would be one solution. Will at least need to see the code where the player loses a life and possibly the entire class of the player (to start). Plus, would need to know exactly what you want done with the player when a life is lost.
danpost danpost

2014/3/18

#
Something I threw together almost a year ago for a livesCounter actor is located here.
You need to login to post a reply.