# How to pause a game

**URL:** <https://forum.kirupa.com/t/how-to-pause-a-game/262317>\
**Category:** Uncategorized\
**Created:** [June 5, 2008, 12:39am UTC](https://forum.kirupa.com/t/how-to-pause-a-game/262317 "2008-06-05T00:39:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RebuiltJorge](https://avatars.discourse-cdn.com/v4/letter/r/94ad74/32.png) [@RebuiltJorge](https://forum.kirupa.com/u/RebuiltJorge)\
**Post date:** [June 5, 2008, 12:39am UTC](https://forum.kirupa.com/t/how-to-pause-a-game/262317/1 "2008-06-05T00:39:03Z")

</div>

ok i have a game that runs on a linear timeline in that certain events are triggered by the amount of time passed in the game, for example if clock == 100, the trigger Super Boss etc etc,

```auto
lastTime = getTimer();

function mainTime(evt:Event){
  timeDiff = getTimer()-lastTime;
  lastTime+=timeDiff;
  var clockTime:Number = timeDiff/1000;

}

```

no too bad right, however at a certain point I would like to pause all events to add a special event, then at I would like to re add the eventListener and have “clockTime” resume where it left off, does that make sense,

I am able to effectively remove the EL and add it back, however, the ‘clockTime’ continues to add even when EL is remove, this makes sense of course, since ‘lastTime’ was initialized at the beginning of the game,

my question is how do i halt ‘clockTime’ from ticking when pausing the game?

---

<div class="post-metadata">

**Author:** ![DiamondDog](https://avatars.discourse-cdn.com/v4/letter/d/74df32/32.png) [@DiamondDog](https://forum.kirupa.com/u/DiamondDog)\
**Post date:** [June 5, 2008, 5:45am UTC](https://forum.kirupa.com/t/how-to-pause-a-game/262317/2 "2008-06-05T05:45:59Z")

</div>

You could maybe try something like this:

```auto
var startTime:int = getTimer();
var clockTime:int;

function mainTime(evt:Event)
{
    clockTime = (getTimer() - startTime)/1000;
}

function specialFunction()
{
    // grab the current time
    var specialFunctionStartedAt:int = getTimer();
    
    // do the special function 
    // ......
    // ......
    
    // when that's all done
    var specialFunctionDuration:int = getTimer() - specialFunctionStartedAt;
    startTime += specialFunctionDuration;
        
}

```

---

<div class="post-metadata">

**Author:** ![RebuiltJorge](https://avatars.discourse-cdn.com/v4/letter/r/94ad74/32.png) [@RebuiltJorge](https://forum.kirupa.com/u/RebuiltJorge)\
**Post date:** [June 5, 2008, 10:50am UTC](https://forum.kirupa.com/t/how-to-pause-a-game/262317/3 "2008-06-05T10:50:19Z")

</div>

Thanks, I will give it a try later

---

<div class="post-metadata">

**Author:** ![RebuiltJorge](https://avatars.discourse-cdn.com/v4/letter/r/94ad74/32.png) [@RebuiltJorge](https://forum.kirupa.com/u/RebuiltJorge)\
**Post date:** [June 5, 2008, 8:41pm UTC](https://forum.kirupa.com/t/how-to-pause-a-game/262317/4 "2008-06-05T20:41:17Z")

</div>

Nice dude, that works! thanks
