Sign in to follow this  

Can't pause/resume spawning timers.

Recommended Posts

Hey everyone !


So i have a simple logic that i want to implement in my game,

i have these two timers in the create function that are supposed to spawnEnemies or spawn energyCapsules.

enemyTimer = * 0.5, spawnEnemy,this) ;energyTimer = * 0.5, spawnEnergyCapsule,this) ;

So if both are enabled at the same time (Which is not what i intend to make), they work just fine.

what i want to do is, i have a state variable, a flag if you want, named it energyFull, that when the player collects enough capsules, enemies will start being spawned, and energyCapsules will stop being spawned. 


So i need the following...

1- The game starts, the energyTimer starts, while enemyTimer stopped. 

2- When enough energyCapsules are collected,


then pause energyTimer and start enemyTimer to start spawning enemies. 

3- Using another timer that counts for 10 seconds for example, after which all energy is lost, the energyFull = false and the reverse happens ( no enemies, more capsules ). 


I tried using enemyTimer.pause() or destroy() as i have seen in another forum topic, specifically this one...


but for me they don't work at all, Help please. 

Thank you. 

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.