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

  • SEARCH
  • Home
  • 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 8855401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:07:37+00:00 2026-06-14T14:07:37+00:00

When creating a player with AS3 and Box2D we can get the player to

  • 0

When creating a player with AS3 and Box2D we can get the player to move however we can’t get the player to move like it would if it was just being moved with AS3 for example x++; as opposed to ApplyImpulse(new b2Vec2(1,0),GetWorldCenter()). How can we get the player to move more like flash, we have also tried ApplyForce and SetPosition which don’t work correctly! The player is very floaty or doesn’t instantly respond to controls, any advice would be greatly appreciated!

If there is a problem would you please explain it instead of downing and leaving?

  • 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-06-14T14:07:38+00:00Added an answer on June 14, 2026 at 2:07 pm

    Why don’t you try using GetLinerVelocity and then a ApplyImpulse, it could work I made with this proprieties and of course I made two function before with the exactly keys…I mean something like :

    The player_normal is just the Player (object) in repose. And of course the player_max_speed and the player_speed are just other proprieties I add to move as I like…

                player_speed = 2;
                player_max_speed = 4;
                player_normal = new b2Vec2(0, 0);
    

    This goes in the function Main.
    The speed and max_speed you set them as a Number var, and the normal is just b2Vec2.

    And this is the key function when you press down and then up the key:

    private function apreto(e:KeyboardEvent):void
            {
                switch (e.keyCode)
                {
                    case 37: 
                        left = true;
                        break;
    } 
    
    private function suelto(e:KeyboardEvent):void
            {
                switch (e.keyCode)
                {
                    case 37: 
                        left = false;
                        break;
    }
    

    Of course the “left” is a boolean. Very easy I think..And you have to do the same with every key (right, up, down) it depends what kind of key you want it. For example the number 37 = key left in the keyboard.

    And then the code to give movement the player(in the update):

    if (player_normal.x >= 0)
                {
                    if (left)
                    {
                        if (player.GetLinearVelocity().x > -player_max_speed)
                        {
                            player.ApplyImpulse(new b2Vec2( -player_speed, 0), player.GetWorldCenter());
                        }
                    }
                }
    

    I hope it could help you…if not let me know, I have an other way that could be more easy.
    If I can answer any of your question I will be grateful to help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a video recorder and would like to create video player to
i am having problem in creating a video player in flash via as3, the
I was thinking of creating a music player with waveform like in zippyshare like
I am creating a streaming player and so far its working fine. I can
Iam creating a Flash AS3 based Poker game for my company. Some like zynga
Creating a pacman-like game, where a player eats objects. When a MovieClip (box) eats
I'm starting my hand at creating a multi-player game using HTML 5 / Javascript.
I'm creating a flex-based video player, using the FLVPlayback component (imported from Flash Pro
I'm creating a simple media player using jlGUI and jAudiotagger libraries. I've used a
I'm creating a 2D game and when the player dies I want the texture

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.