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

    ActionScript Help!

    Hey guys! I'm kinda new to ActionScript 3. I'm making a game that consists of a character who runs and jumps through obstacles. Can you guys please help me with the coding for the jumping??

    What's the difference between this and _root?

  2. #2
    The Little Frij
    Join Date
    Jul 2010
    Location
    Miss
    Posts
    1,698

    Re: ActionScript Help!

    Quote Originally Posted by RainbowRider
    Hey guys! I'm kinda new to ActionScript 2. I'm making a game that consists of a character who runs and jumps through obstacles. Can you guys please help me with the coding for the jumping??

    And also what does this._x mean??
    I can't help you with the jumping and I would quite like to know how to do it myself, but _x is refering to the X axis on the stage. If you set your character to move on the X axis he will only move <-- this way and --> that way.

    Also, I think that this belongs in the Help/Suggestion area, so post anymore quires there next time

  3. #3
    Ian
    Ian is offline
    Dedicated Member Ian's Avatar

    Join Date
    May 2011
    Location
    England
    Posts
    758

    Re: ActionScript Help!

    I think that this code might work

    [spoiler:27fu5yur]
    Code:
    onClipEvent (load) {
     var isJumping = false;
     var hgt = 0;
    }
    
    onClipEvent (enterFrame) {
     if (Key.isDown(*Key you want to make character jump*)) {
      //this only in case you got some frames within the character
      //special to reproduce when jumping.
     
     this.gotoAndStop("jump_frame");
      //now we set the jumping variable to true
      //because we are jumping :D
     
     jumping = true;
     }
     if (jumping) {
      //now we catch that it is performing a jump
      //and increase the jump-units variable by 1
     
     hgt++;
      //now let&#39;s say the jump capacity is three-jump-units
      //this means that max height will be 3*40, because in this case
      //I&#39;m setting 40 height-units for every 3 jump-units
      //you can set any variables you like here, maybe if your game
      //has upgrades
     
     if (hgt<3 && hgt>0) {
       //this means our character is going up
     
      this._y -= 40;
      }
      //now the max height is reached, we want it to go down 
      //the same jump-units it went up this means 3*2 = 6
      //so when our jump-unit counter reach 6 means that our
      //character is in the floor (you can also set the floor
      //to a variable) and we should stop doing jumping stuff
    
      if (hgt>3 && hgt<6) {
       this._y += 40;
      }
      //here we get hgt == 6 so floor is reached and we 
      //need to reset all variables and do stop-jumping stuff 
     
     if (hgt == 6) {
       //reset the jump-units, ready for the next jump 
      
     hgt = 0;
       this.gotoAndStop("normal_position");
       //we are not jumping any more 
      
     jumping = false;
      }
     }
    }
    Here is a link to the page I got this from:

    Jumping in actionscript[/spoiler:27fu5yur]



    Projects:

    none

    SLASHED 2012!

  4. #4
    Global Champyon Stickid's Avatar



    Join Date
    Aug 2006
    Location
    Mexico
    Posts
    4,307

    Re: ActionScript Help!

    It'd make sense for this thread to be in Flash Discussion / Showcase, but I feel like you'll get less help there.

    Thread moved to Help / Suggestion Centre

  5. #5
    Fresh Newbie RainbowRider's Avatar
    Join Date
    Dec 2012
    Posts
    8

    Re: ActionScript Help!

    Quote Originally Posted by Stickid
    It'd make sense for this thread to be in Flash Discussion / Showcase, but I feel like you'll get less help there.

    Thread moved to Help / Suggestion Centre
    Thanks for letting me know!


 

Posting Permissions

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