XNA tempory pause

Posted by Marivs on Game Development See other posts from Game Development or by Marivs
Published on 2014-06-08T16:06:20Z Indexed on 2014/06/08 21:42 UTC
Read the original article Hit count: 155

Filed under:
|
|

I need to do a temporary pause. If I do a collision with an enemy I want to pause the game for 1.5 seconds. Take a look here to my code:

bool tPause;
float timer;

public ovveride Update(GameTime gameTime)
{
    if(!tPause)
        {
            //...
            if(enemy.rectangle.Intersects(player.rectangle))
            {
                timer+=(float)gameTime.ElapsedGameTime.TotalMilliseconds;
                tPause=true;
                if(timer>1500)
                {
                    tPause=false;
                    timer=0;
                }
            }
            //...
        }
}

It doesn't function.

© Game Development or respective owner

Related posts about XNA

Related posts about c#