Sign In Register

How can we help you today?

Start a new topic
Answered

How to create a Count Down functionality

Hi all,


I would like to create a count down feature on my game just like the lives in Candy Crush or Trivia Crack. Every 60 minutes, the player gets a new life (up to 3 lives).


So my first question is: is it a good idea to control the player's lives from the backend side or simply having a countdown timer in the client itself suffices?


If choosing GameSparks to build this, what should be my approach? What functions in Cloud Code should be used? Do I create a new Player property where the client keeps reading from?


Thanks!


Best Answer

I think the best way is to have a timer on the client, and when that is done it calls an event with cloud code that compares the current time to the last time the user was granted a life. If the cloud code determines that it has been 60 minutes then you respond to the client with a success boolean and if not, just send back the remaining time and have the client's timer update. This way you're not doing much code in the cloud and also user's can't just fast forward time in the client or try to cheat. I'll be doing something similar with my game soon.


I'm still new to Gamesparks but this way seems to make sense in my head. 


Answer

I think the best way is to have a timer on the client, and when that is done it calls an event with cloud code that compares the current time to the last time the user was granted a life. If the cloud code determines that it has been 60 minutes then you respond to the client with a success boolean and if not, just send back the remaining time and have the client's timer update. This way you're not doing much code in the cloud and also user's can't just fast forward time in the client or try to cheat. I'll be doing something similar with my game soon.


I'm still new to Gamesparks but this way seems to make sense in my head. 


1 person likes this

Thanks Sean! Your suggestion makes sense indeed! I will try to create something like that myself. Cheers

Login to post a comment