Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4069848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:33:08+00:00 2026-05-20T16:33:08+00:00

onClipEvent(enterFrame){ speed = 8; jump = 20; gravity = 10; // gravity this._y+=gravity; _root.cam._y

  • 0
    onClipEvent(enterFrame){
    speed = 8;
    jump = 20;
    gravity = 10;

    // gravity
    this._y+=gravity;
    _root.cam._y = this._y;

// movement
    if(Key.isDown(68)){
        play();
        _root.cam._x += speed;
        this._x += speed;
        _xscale=90
       }
     if(Key.isDown(65)){
         play();
        _root.cam._x -= speed;
        this._x -= speed;
        _xscale=-90
       } 

       if(Key.isDown(Key.SPACE)){
        this._y -= jump;
        jump--;
       }


      if(this, hitTest(_root.wall)){
          this._y-=(gravity);
       }

}   //END 

So I’m trying to make an movie clip that I have “jump” whenever i hit space. It should decrement the jump speed when i hit space, but it doesnt seem to do that. Can anyone tell me why? (the code here is directly on my mc)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T16:33:09+00:00Added an answer on May 20, 2026 at 4:33 pm

    You need to introduce a new variable to keep track of the y-velocity. Then, instead of incrementing the y-position by gravity each frame, you need to increment the y-velocity by gravity. At the end of each frame, you can increment y-position by y-velocity.

    Whenever you want to jump, its a matter of setting the y-velocity to a negative value.

    Pseudocode:

    dy+=GRAVITY;
    if(jump pressed)
        dy=-JUMP_SPEED;
    y+=dy;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've coded a little game, but now I realized that I should include all
I am using the following code to load my flash file, contact a php
I want to make a movieclip invisible initially but i dont want to set
I am trying to create a link on a page that mimicks the existing
I've got a custom view and I want to get the X and Y
I have successfully implemented my AutoCompleteTextView which is based off an SQLite query and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.