There is the following platform:

enter image description here

And a coin above it:

enter image description here

And the following code using arcade physics:

gravity: { y: 100, x: 10 }, - in config

function preload ()
this.load.image('platform', 'assets/platform.png');
this.load.image('star', 'assets/star.png');

function create ()
platforms = this.physics.add.staticGroup();

platforms.create(400, 568, 'platform');

player = this.physics.add.sprite(100, 450, 'star');


The code is approximate, a coin above the platform, sprites in png format. But the coin falls and does not roll, but moves horizontally, after which it falls again. How to make it "roll"?

UPD: Will it help me? https://github.com/photonstorm/phaser-examples/blob/master/examples/arcade%20physics/circle%20body.js And how to be with the platform?

  • 1
    \$\begingroup\$ In the image, you can see the front and right side of the coin. If you just rotate the image, you'll see the front and bottom. Perspective will be messed up. You would need to animate it somehow \$\endgroup\$ – Peethor Feb 19 '19 at 9:05
  • \$\begingroup\$ But how will animation help physics? \$\endgroup\$ – Timur Musharapov Feb 19 '19 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.