Search the Community
Showing results for tags 'setCircle'.
-
I have a staticGroup of floating coins from a tilemap and I wanted to make the collision area circular and the correct size however: I tried calling `setCircle` on each object in the group but it has no effect. If I change the staticGroup to a group, I can see the circle form when using debug mode. However this then subjects the group to gravity and my objects fall out of the game Here's the relevant code: function create() { var coinTiles = map.addTilesetImage('coin'); coinLayer = map.createDynamicLayer('Coins', coinTiles, 0, 0); // I tried changing this to this.physics.add.group(); coinGroup = this.physics.add.staticGroup(); // Loop over each Tile and replace sprite coinLayer.forEachTile(tile => { if (tile.index === 17) { const x = tile.getCenterX(); const y = tile.getCenterY(); const coin = coinGroup.create(x, y, "coin"); // This line seems to have no effect on static objects. coin.body.setCircle(10, 10 , 10); coinLayer.removeTileAt(tile.x, tile.y); } }); // etc... } staticGroup: Group: (ignore circle offset being completely off)
- 5 replies
-
- floating
- staticgroup
-
(and 3 more)
Tagged with:
-
Hi guys, new to Phaser so maybe this isn't a bug. I searched on the forum but i cannot find any information about it, hope it will be not already asked. I found an issue regarding the circle body collider, in particular when scaling a sprite the circle collider doesn't fit the new scale of the sprite. You can try this out by modify the "Circle vs Polygon" example, just add this line of code: "sprite4.scale.setTo(0.7, 0.7);" after creating sprite4 in create() function. You can find an image attached. The fact is that if you remove the circle body (using the rect one) everything's fine. I think that is possible to modify the center of the collider manually, but i wanted to signal the problem.