Hello and welcome to our community! Is this your first visit?
Register
Results 1 to 2 of 2
  1. #1
    Fresh Newbie RainbowRider's Avatar
    Join Date
    Dec 2012
    Posts
    8

    Help with coding AS3

    So basically I'm creating a game and Im stuck on the jumping. Help Plz!
    [spoiler:3rm18c5a]import flash.ui.Keyboard;
    import flash.events.MouseEvent;

    var spd = 5;
    var isJumping = false;
    var jumpSpeed = 0;
    var startY = 185.4;


    stage.addEventListener(KeyboardEvent.KEY_DOWN, manMove)
    function manMove(e:KeyboardEvent){
    if(e.keyCode == Keyboard.RIGHT){
    man.x += spd;
    trace("RIGHT KEY IS PRESSED");
    man.scaleX = 1
    man.play();
    }else{
    if(e.keyCode == Keyboard.LEFT){
    man.x -= spd;
    man.scaleX = -1;
    man.play();
    trace("LEFT KEY IS PRESSED");
    }else{
    if (isJumping) {
    man.y += jumpSpeed;
    jumpSpeed += 1;
    if (man.y>=startY) {
    man.y = startY;
    isJumping = false;
    spd = 6;
    }
    } else {
    if (e.keyCode == Keyboard.UP) {
    isJumping = true;
    jumpSpeed = -15;

    } else {
    stop();


    }
    }
    }
    }
    }


    }[/spoiler:3rm18c5a]

  2. #2
    Newbie Keli's Avatar
    Join Date
    Jan 2013
    Location
    Australia
    Posts
    24

    Re: Help with coding AS3

    What are you stuck with exactly? I'm assuming you don't want to prevent your character from jumping all together, so what's the exact issue?
    [center:8n4kwpj2][/center:8n4kwpj2]


 

Posting Permissions

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