zelcard Posted August 31, 2016 Share Posted August 31, 2016 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 More sharing options...
Cybercell Posted August 31, 2016 Share Posted August 31, 2016 Hi, I would use vectors to rotate the ball and player. Example 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! zelcard 1 Link to comment Share on other sites More sharing options...
samme Posted August 31, 2016 Share Posted August 31, 2016 @zelcard Which physics are you using? Link to comment Share on other sites More sharing options...
zelcard Posted August 31, 2016 Author Share Posted August 31, 2016 I'm going with P2 Physics since they support more complicated shapes than Arcade Physics. Link to comment Share on other sites More sharing options...
samme Posted August 31, 2016 Share Posted August 31, 2016 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). lumoludo and zelcard 2 Link to comment Share on other sites More sharing options...
zelcard Posted August 31, 2016 Author Share Posted August 31, 2016 Thank you very much, both of you. I'll try to work something out with the information you have provided. I'll let you know if I manage to put it together. Thanks! Link to comment Share on other sites More sharing options...
Tom Atom Posted August 31, 2016 Share Posted August 31, 2016 Definitely the easiest way is to add player to group (add()) or wheel spirte (addChild()) on touch and remove it from again on jump. Then player will rotate together with wheel without any further effort. Link to comment Share on other sites More sharing options...
Recommended Posts