A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Isometric Game +jump

  1. #1
    Junior Member
    Join Date
    Jan 2003
    Location
    !
    Posts
    1

    Isometric Game +jump

    Hi, everyone, I try something for a isogame
    and where i can jump, but when i hold down the key(spacebar)
    my ball still in the air.

    I want a know if there's a way to block a key.Space so even if we hold down the key the ball fall down,

    here's the code for the jump:
    // Movement along y - axis;
    jumping = false;

    if(Key.isDown(Key.SPACE)&&!jumping){vy=-35

    }

    Vy = Vy + A

    y = Vy;

    if(jumping = true)

    if (y >= 0) {
    y = 0;
    }
    Frenzal Hulkzen

  2. #2
    Senior Member
    Join Date
    Jan 2001
    Location
    HK | Toronto
    Posts
    989
    To do something like "trigger once", we can always use a FLAG
    When we trigger that event, the FLAG variable will change >> avoid continuous signals sending off... Until you release the space, for instance, the FLAG will return to the normal state that accepts the event again.

    so a semi-script will look like...
    FLAG=0; //or flag!=1 ...
    if (space bar is pressed and FLAG=0) {
    Character start jumping;
    FLAG=1;
    }
    so when you pressed SpaceBar, the FLAG will change to 1 and no more jumping is available
    It will be good to detect several thing to allow the character to jump again, like return to the ground? SpaceBar is release?... meet both then FLAG=0 again (allow users to jump again)

    Hope it helps

    MKit

  3. #3
    Member
    Join Date
    Dec 2002
    Posts
    46
    Okay no offence mkit but you dont make sence to me, and probably not to him, and this is jumping.. who would only want to jump once..

    okay fren.. With help from mcnugget (he knows everything and more) i have a sollution.. Its quite simple really. Here is all the code i am using

    This code is on my square thats on the stage.

    onClipEvent (load) {
    jumping = false;
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.Space) and jumping == false) {
    jumping = true;
    _root.abc.gotoAndStop(2);
    }
    }


    only things you need to change is probably the frame number (2) the _root.abc and the jumping to your liking..

    Now that we have the jump made, you just need to open up your jump animation, if you have any, and add this to the last frame:

    _root.abc.jumping = false;
    _root.abc.gotoAndStop(1);


    And of course, changing the frame number, and MC name.

    So you might want to add a bit more, and play with it.. but heres a fla file.
    Attached Files Attached Files
    Last edited by 1169; 01-13-2003 at 09:58 AM.

  4. #4
    Senior Member
    Join Date
    Jan 2001
    Location
    HK | Toronto
    Posts
    989
    Originally posted by MKit
    To do something like "trigger once", we can always use a FLAG
    When we trigger that event, the FLAG variable will change >> avoid continuous signals sending off... Until you release the space, for instance, the FLAG will return to the normal state that accepts the event again.

    so a semi-script will look like...
    FLAG=0; //or flag!=1 ...
    if (space bar is pressed and FLAG=0) {
    Character start jumping;
    FLAG=1;
    }
    so when you pressed SpaceBar, the FLAG will change to 1 and no more jumping is available
    It will be good to detect several thing to allow the character to jump again, like return to the ground? SpaceBar is release?... meet both then FLAG=0 again (allow users to jump again)

    Hope it helps

    MKit
    1169
    Man USE YOUR EYE..., the last sentence, I told u to set the Flasg back to 0 AND ALLOW THE CHARACTER to JUMP again... the original problem is continuous triggering, the way to solve is using Flag

    MKit

  5. #5
    Also, Frenzal. In your code you're using = to compare..eg: if(jumping = true) = is the assignment operator. You must use == which is the logical equality comparison.

    if(jumping == true){
    //do this or that;
    }

    I have a little Mario-like Jump FLA that you can analyze here .
    Last edited by jonwiz; 01-13-2003 at 04:07 PM.

    www.jonwiz.com
    Drop by for-->MX Component Downloads, Games, Music, Blog, Art & more...

  6. #6
    Senior Member
    Join Date
    Jan 2001
    Location
    HK | Toronto
    Posts
    989
    Originally posted by 1169

    onClipEvent (load) {
    jumping = false; (Flag=0)
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.Space) and jumping == false) {
    jumping = true; (FLAG=1)
    _root.abc.gotoAndStop(2);
    }
    }

    _root.abc.jumping = false; (FLAG=0)
    _root.abc.gotoAndStop(1);

    1169 you are using the same idea too. I mean your idea from McNugget. It is something like FLAG. anyway hope you will get it

    MKit

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