Jump to content

Rotate two sprites together


zelcard
 Share

Recommended Posts

Hello guys,

I'm trying to make a game similar to Jump Nuts here is a video: 

I'm stuck with making my player sprite stick to the wheel sprite(on collision) and rotate along with it, what do you guys think would be the easiest way to do this? The thing I have tried is setting the same pivot point (on collision) for both player and wheel sprite but the player sprite just dissapears from the screen. Thanks.

Link to comment
Share on other sites

Hi,

I would use vectors to rotate the ball and player.

Example gif: CosineAndSine.gif

Imagine if this circle is the little ball where the player should stand on.

Now the white line is the distance the player should be placed from the center of the circle(so it looks like its standing on the ball, also make sure your players anchor point is at this feet).

If you want to jump you just apply a force in the direction your hero is facing and let gravity do the work.

Hope it helps!

Link to comment
Share on other sites

pivot is more like an anchor than a position: http://phaser.io/examples/v2/sprites/pivot . I don't know about the physics part but try:

  • zero the player's motion
  • set the player's position to the wheel's position
  • set the player's pivot to the wheel's radius
  • set the player's rotation to the wheel's rotation

But the hard part is placing the player correctly while changing its pivot (when it enters or leaves the wheel).

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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