2

So I'm making a simple coin dropping game I have already created coin objects with a simple Bodies.circle. However I want to replace that with a coin image. This is what I have so far.....

    this.body = Bodies.circle(x, y, r, {

    restitution: 1,
    friction:0,
    render: { 
        sprite:{ 
            texture: 'images/coin.png'
        }
    }
    });
    this.r = r; 
    World.add(world, this.body);  
} 
ggorlen
  • 44,755
  • 7
  • 76
  • 106
Eskimo
  • 43
  • 8
  • 2
    It depends on how you render your matter.js physics objects. You could simply request the position of the body with this.body.position.x (and y) and simply place your png at that position (do that 30 times per second) – Kokodoko Mar 15 '17 at 14:19
  • What's the problem with the code now exactly? – ggorlen Apr 05 '22 at 01:59
  • Related: [how to round an image in matter.js](https://stackoverflow.com/questions/72468816/how-to-round-an-image-in-matter-js/72849934#72849934) – ggorlen Dec 24 '22 at 22:45

0 Answers0