Health in game

Is there a way to implement health in game and after every minute you lose one health ? It would be awesome if someone could show me how to

You have the timer.performWithDelay function that will execute a function if you like every XX milliseconds… you just need to create a function to decrease the count of health by 1 and call it from the timer :slight_smile:

Hope it helps!

Are you trying to make a health bar? Are you trying to make like 3 hearts on the screen and then it goes to 2 hearts and then 1 and then you lose? Can you explain? There are different approaches to different things. Thanks!

–SonicX278

I’m doing something similar. I was able to do say 3 lives decreasing to 2 then 1 then 0. After 30 minutes or so number of lives would be increased by 1. My issue is:

1 - How to persist the time across the screens?

2 - The timer countdown stops when the user is not playing. How to give the user back lives after he has exited the app more than 30 minutes.

This might help:
 

https://coronalabs.com/blog/2013/05/14/sprites-and-image-sheets-for-beginners/

Rob

uh…we’re talking about timers here, Rob.

Ken

You have the timer.performWithDelay function that will execute a function if you like every XX milliseconds… you just need to create a function to decrease the count of health by 1 and call it from the timer :slight_smile:

Hope it helps!

Are you trying to make a health bar? Are you trying to make like 3 hearts on the screen and then it goes to 2 hearts and then 1 and then you lose? Can you explain? There are different approaches to different things. Thanks!

–SonicX278

I’m doing something similar. I was able to do say 3 lives decreasing to 2 then 1 then 0. After 30 minutes or so number of lives would be increased by 1. My issue is:

1 - How to persist the time across the screens?

2 - The timer countdown stops when the user is not playing. How to give the user back lives after he has exited the app more than 30 minutes.

This might help:
 

https://coronalabs.com/blog/2013/05/14/sprites-and-image-sheets-for-beginners/

Rob

uh…we’re talking about timers here, Rob.

Ken