Jump to content

Spinning wheel physics


Areg
 Share

Recommended Posts

Hi there.

 

I have a sprite, it is a wheel. I set it's anchor to it's center. I need to add spinning ability to it by input :  holding mouse on some edge of that wheel, dragging it around its center(anchor), and releasing mouse so that it will spin on and on, and will have a force applied to it that will make it slow down it's speed until it's stopped (basically, natural spinning of a wheel).  I suppose I should use Phaser's Physics for it, but which one? And are there any methods to do that?

 

Thanks.

Link to comment
Share on other sites

I'm thinking you could tween rotation of your wheel sprite, and pick an easing that slowed towards that end.

 

However, that might not be enough to slow it "realistically".  You might have to control the degree of rotation your self, in update via your own formula.

Link to comment
Share on other sites

a tween would always lead to sort of the same outcome.. so its probably not the best solution for something like roulette for example.

every rotating object in p2 has already a force that stops it.. its called angularDamping..

i would probably work with constraints. one little circle as axis body.static so it can not move and the wheel directly above it. body.dynamic of course.. connected by a distance constraint with 0 distance.

myconstraint.collideConnected to false so they wont collide with each other..

thats your wheel.. the bigger problem will be the grab and rotate part.

i submitted an example - its in the official repos - on how to grab a circle body and throw it away.. maybe we could alter it a little bit to fit in your usecase

http://phaser.io/examples/v2/p2-physics/mouse-spring

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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