How do you implement a Countdown clock?

gecenab

  • Posts: 31
Hello Stencyl community. I'm new to the forum. I'm not new to programming, but I'm new to Stencyl... Only around two months working with Stencyl, but I'm really getting the grip of it.

My question is, can anyone help me on how to implement a countdown clock?

The main idea of this clock is to add a new "life" to the player after a given amount of time. I already have a normal clock that increments every second, so countdown just needs a decrement instead of a increment.

But the part that is giving me trouble is this countdown clock should work pretty much like the ones used in games like candy crush and similars. So it should stay active even when the game is off. I can't figure it out.

Please help!

squeeb

  • Posts: 1617
I have that in my stencyl marketplace
http://community.stencyl.com/index.php/topic,50022.0.html

Energy and Lives Regeneration and Daily and Weekly Events  $3 USD (http://www.stencyl.com/game/play/35930)
Lives and Energy is regenerated over your pre determined time,  Set up Daily and Weekly Events and Rewards to your game or application. this even works when the Device is off or the game has been closed out

LIBERADO

  • *
  • Posts: 2720
The Date Extension will be useful for you.
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

gecenab

  • Posts: 31
Thanks for your answers. I'll be checking the links you left me.

« Last Edit: August 16, 2017, 08:28:56 am by gecenab »

gecenab

  • Posts: 31
Still can't figure it out. Anyone got an example running?


I have that in my stencyl marketplace
http://community.stencyl.com/index.php/topic,50022.0.html

Energy and Lives Regeneration and Daily and Weekly Events  $3 USD (http://www.stencyl.com/game/play/35930)
Lives and Energy is regenerated over your pre determined time,  Set up Daily and Weekly Events and Rewards to your game or application. this even works when the Device is off or the game has been closed out

Tried your link but I could only find the flash example of your work.

NickamonPoppytail

  • Posts: 1141
Gecenab,

If you need a countdown, just create a 'Do after/every _ seconds' event, and if you're using game attributes, use this:

Do every (number) seconds:
Set (attribute) to (attribute) - (number)

You could also use an if statement for that and then use an 'otherwise if':

Otherwise if (attribute) = 0
Set (attribute) to (number)*

*You could make it reset, you could just keep it at 0 and then use a different event to restart.

Also, make sure you use a drawing event if you want the clock on screen.
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH. One Million: Last-one-standing style small project. The Poppytales: Platformer boss rush with character collecting. Skies n' Fall: Boss rush shooter prequel to Rise n' Brawl. Precious: Weird platformer. Christmas Time 2: Sequel to Christmas Time 1.

thechaosengine

  • *
  • Posts: 329
Gecenab,

If you need a countdown, just create a 'Do after/every _ seconds' event, and if you're using game attributes, use this:

Do every (number) seconds:
Set (attribute) to (attribute) - (number)

You could also use an if statement for that and then use an 'otherwise if':

Otherwise if (attribute) = 0
Set (attribute) to (number)*

*You could make it reset, you could just keep it at 0 and then use a different event to restart.

Also, make sure you use a drawing event if you want the clock on screen.

I don't think this would work when the game is closed.

I use the Date Extension that LIBERADO linked to, setting a 'lastsavedtime' game attribute to [get current timestamp] and compare that to another attribute that's set to a certain number like half an hour or whatever. I also tried Squeeb's product but it was far too complicated for me lol

gecenab

  • Posts: 31
Yeah... I don't think that would work with game closed.
Gecenab,

If you need a countdown, just create a 'Do after/every _ seconds' event, and if you're using game attributes, use this:

Do every (number) seconds:
Set (attribute) to (attribute) - (number)

You could also use an if statement for that and then use an 'otherwise if':

Otherwise if (attribute) = 0
Set (attribute) to (number)*

*You could make it reset, you could just keep it at 0 and then use a different event to restart.

Also, make sure you use a drawing event if you want the clock on screen.

I don't think this would work when the game is closed.

I use the Date Extension that LIBERADO linked to, setting a 'lastsavedtime' game attribute to [get current timestamp] and compare that to another attribute that's set to a certain number like half an hour or whatever. I also tried Squeeb's product but it was far too complicated for me lol

I don't think that would work when game closed...

Any other options???

NickamonPoppytail

  • Posts: 1141
What do you mean by if the game is closed? You could use this as a 'when created' event on any scene you want this to appear, or use it as a behaviour.
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH. One Million: Last-one-standing style small project. The Poppytales: Platformer boss rush with character collecting. Skies n' Fall: Boss rush shooter prequel to Rise n' Brawl. Precious: Weird platformer. Christmas Time 2: Sequel to Christmas Time 1.

NickamonPoppytail

  • Posts: 1141
By the way, I have made a few Stencyl games and the event I described works as I intended, and it sounds like you wanted the same thing to happen.
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH. One Million: Last-one-standing style small project. The Poppytales: Platformer boss rush with character collecting. Skies n' Fall: Boss rush shooter prequel to Rise n' Brawl. Precious: Weird platformer. Christmas Time 2: Sequel to Christmas Time 1.

gecenab

  • Posts: 31
What do you mean by if the game is closed? You could use this as a 'when created' event on any scene you want this to appear, or use it as a behaviour.

I mean like Candy Crush... Every time you play it consumes energy/life, and then every 10 minutes or so you get an extra life. But even if you close he game the timer keeps on running, so when you have used your five energies/lifes and close the game to do something else your energy/life counter fills up again even if the game is closed.

squeeb

  • Posts: 1617
By the way, I have made a few Stencyl games and the event I described works as I intended, and it sounds like you wanted the same thing to happen.
Try that.  And then restart the decice... the time data is lost
My mechanic works.  Ceosol wrote the code.  I had to figure out how it works.  Once you read through it.  It's easy to use.  Im puttimg it into my games now.   I need some time to make it a little more user friendly in a behaviour maybe

NickamonPoppytail

  • Posts: 1141
What do you mean by if the game is closed? You could use this as a 'when created' event on any scene you want this to appear, or use it as a behaviour.

I mean like Candy Crush... Every time you play it consumes energy/life, and then every 10 minutes or so you get an extra life. But even if you close he game the timer keeps on running, so when you have used your five energies/lifes and close the game to do something else your energy/life counter fills up again even if the game is closed.

I see what you mean now.
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH. One Million: Last-one-standing style small project. The Poppytales: Platformer boss rush with character collecting. Skies n' Fall: Boss rush shooter prequel to Rise n' Brawl. Precious: Weird platformer. Christmas Time 2: Sequel to Christmas Time 1.

gecenab

  • Posts: 31
By the way, I have made a few Stencyl games and the event I described works as I intended, and it sounds like you wanted the same thing to happen.
Try that.  And then restart the decice... the time data is lost
My mechanic works.  Ceosol wrote the code.  I had to figure out how it works.  Once you read through it.  It's easy to use.  Im puttimg it into my games now.   I need some time to make it a little more user friendly in a behaviour maybe

Yeah.... when are you planning to have it finished as an user friendly behaviour??

squeeb

  • Posts: 1617
I will take a look tonight and see what I need to do, and let you know... I can probably get it done within a few days