Jump to content

Predective Projectile Motion of an object using javascript,Box2d and HTML5


Recommended Posts

Hi Team,


I am developing an app using cocos2d game engine. I am using box2d as physics engine. I want to move a particle when on clicked will show a predecitve projectile path and when released the object should move in the same path as the predected motion.(This requirement resembles angry birds game).


Please help if anyone is aware of how to achieve this.


I am attaching a sample project where the bird is launced but the projected motion is not show in the current project.Please help on the same.


Thanks and Regards,



Link to comment
Share on other sites

How to launch a body towards the mouse cursor

var bodyVelocity = body.GetLinearVelocity();//grab the bodys velocityvar launchDirection = body.GetPosition();//grab the bodys position to calculate launch directionlaunchDirection.Subtract(mousePositionWorld.x,mousePositionWorld.y);//subtract the mouse position in box2d space from body position to get the launch direction vectorlaunchDirection.Normalize();//normalize the launch direction so its consistent no matter how far the mouse is from the bodybodyVelocity.SetV(launchDirection);//set the bodys velocity to the launch direction
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...