A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [HELP] How to make a fixed pause with letter P?

  1. #1
    I'm not Crazy :D
    Join Date
    Nov 2015
    Location
    Brazil [<o>]
    Posts
    86

    Question [HELP] How to make a fixed pause with letter P?

    Hello guys, how to pause with the letter P with add listener or something, except this example:

    Code:
    if (Key.isDown(letter))
    {
    pause = true;
    }

  2. #2
    Member
    Join Date
    Sep 2014
    Posts
    77
    Quote Originally Posted by CrazY. View Post
    Hello guys, how to pause with the letter P with add listener or something, except this example:

    Code:
    if (Key.isDown(letter))
    {
    pause = true;
    }

    PHP Code:
    var listener:Object = new Object();
    listener.onKeyDown = function() {
        if (
    Key.getCode() == 80) {
            
    trace("P-Key Pressed.");
            
    pause true;
        }
    };
    Key.addListener(listener); 

  3. #3

  4. #4
    I'm not Crazy :D
    Join Date
    Nov 2015
    Location
    Brazil [<o>]
    Posts
    86
    Thank you guys :P, but, case the pause is true, and the player press letter P to unpause the game, this is valid?

    PHP Code:
    var listener:Object = new Object(); 
    listener.onKeyDown = function() { 
        if (
    Key.getCode() == 80) { 
        if (!
    pause)
        {
                
    pause true;
        }
        else
        {
            
    pause false;
        }
        }
    }; 
    Key.addListener(listener); 

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    Try something along the lines of

    PHP Code:
    var isPaused:Boolean false;

    function 
    doPause(arg:Boolean):Void
    {
        if (
    arg)
        {
            
    trace("Paused");
        }
        else
        {
            
    trace("unPaused");
        }
    }

    var 
    pListener:Object = new Object();
    pListener.onKeyDown = function():Void 
    {
        if (
    Key.getCode() == 80)
        {
            
    isPaused = !isPaused;
            
    doPause(isPaused);
        }
    };
    Key.addListener(pListener); 

  6. #6
    I'm not Crazy :D
    Join Date
    Nov 2015
    Location
    Brazil [<o>]
    Posts
    86
    This seems to suit me, thanks man.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center