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 3665972
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:49:30+00:00 2026-05-19T01:49:30+00:00

I’m making a game like Arkanoid and to move the ship with mouse, I’m

  • 0

I’m making a game like Arkanoid and to move the ship with mouse, I’m using the following code :

var mousex:int = costume.stage.mouseX;
if (mousex < paddleWidth/2)
    mousex = paddleWidth/2;
else if (mousex > PhysiVals.STAGE_WIDTH - paddleWidth/2)
    mousex = PhysiVals.STAGE_WIDTH - paddleWidth / 2;

var idealLocation:Point = new Point(mousex, ypos);

var directionToTravel:b2Vec2 = new b2Vec2((idealLocation.x -> costume.x) * PhysiVals.paddleSpeed, idealLocation.y-costume.y);

directionToTravel.Multiply(1 / PhysiVals.RATIO);

directionToTravel.Multiply(30);

body.SetLinearVelocity(directionToTravel);

Everything’s going fine there! The paddle is moving the way it should! The problem is I want a little inclination towards the direction its moving and when it stops moving the angle of inclination should become zero. I tried playing with the angular velocity but I have no real idea how to do this! So Please help!

  • 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-19T01:49:31+00:00Added an answer on May 19, 2026 at 1:49 am

    The angular velocity of a body is its rotation speed and if I remember correctly Box2D measures it in radians/second. So if you set it to 1 you should see a slow rotation.

    body.SetAngularVelocity(1);
    

    (If you don’t, it might mean that I’m wrong about the units, or it might mean that you have a constraint on the body preventing it from rotating.)

    However it sounds like you want the body to move to a specific angle. There is a function SetXForm which allows you to specify a new position and angle but if you use that then you’ll mess with the contact system and Box2D recommends against using this unless an item has genuinely teleported from place to place.

    Your paddle isn’t doing that, so maybe you could try this.

    body.SetAngularVelocity((targetAngle - body.GetAngle()) * x);
    

    x here is a constant which controls the speed of the rotation. Setting it to the clip’s FPS will cause the body to snap within a frame to the right angle. Setting it lower will cause a slower, smoother rotation to the required angle, but it will also make the body’s rotation more susceptible to influence by contact with other bodies.

    The same trick works in order to move the body to a set target location, but it’s more verbose:

    var delta:b2Vec2 = new b2Vec2(target.x, target.y);
    delta.Subtract(body.GetPosition());
    delta.Multiply(x);
    body.SetLinearVelocity(delta);
    

    It goes without saying that neither of these will work if there’s some other static body in the way preventing the motion. Also, by using either of these, you’re overwriting the angular/linear velocities Box2D is generating, which means you’re going against the grain of the simulation.

    caveat: code isn’t tested, and was written from memory

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm making a simple page using Google Maps API 3. My first. One marker
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

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.