Monday, July 8, 2013

Add Action Game Ingredients

I had quite a bit of a challenge trying to modify the timer code to do exactly what I wanted. It took a while, but I got it figured out. Here's what I had to do:

I have an array of flowers holding pollen. When the player collides with one of the flowers, it disappears and you see the pollenless flower that's on a layer behind it. A for loop cycles through these flowers and determines if they should be visible or not.

So I created a timer that counts up. I also created an array of values called 'flowertime'. When the player collides with one of the flowers, the current timer value gets stored in the corresponding 'flowertime' array.

Then I check if the current value of the timer minus the 'flowertime' is over five seconds. If it is, I make the corresponding flower visible again.

No comments:

Post a Comment