Holger Posted April 20, 2017 Share Posted April 20, 2017 Hi, i am creating a sprite and add a second sprite as child. When I render the collision bounds the bounds for the added child are displayed on the wrong position. The transformation of the parent is missing. On the screenshot the pentagon is a child of the circle and the polygon for the bounds is displayed on the wrong position. <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Phaser Hello World</title> <script type = "text/javascript" src="./phaser-ce-2.7.6/build/phaser.min.js"></script> </head> <body> <div id="gameContainer" class="game-container"></div> <script type="text/javascript"> var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', {preload: preload, create: create}); function preload() { game.load.image('circle', 'test/images/images.png', 225, 225); game.load.image('fuenfeck', 'test/images/fuenfeck.png'); } function create() { game.stage.backgroundColor = '#ffffff'; game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.gravity.y = 1000; sprite1 = game.add.sprite(50, 400, 'fuenfeck'); sprite1.scale.x = 0.5; sprite1.scale.y = 0.5; game.physics.p2.enable(sprite1, true); sprite1.body.clearShapes(); sprite1.body.addPolygon({}, 0, 15, 10, 45, 40, 45, 50, 20, 25, 0); sprite1.body.data.gravityScale = 0; sprite2 = game.add.sprite(100, 200, 'circle'); sprite2.scale.x = 0.5; sprite2.scale.y = 0.5; game.physics.p2.enable(sprite2, true); sprite2.body.setCircle(45); sprite2.body.data.gravityScale = 0; sprite2.addChild(sprite1); } </script> </body> </html> I need this functionality for collision detection. I only want to check the collision between another sprite and the child. Is this a bug or am I missing something... thanks a lot Holger Link to comment Share on other sites More sharing options...
Holger Posted April 28, 2017 Author Share Posted April 28, 2017 I changed my implementation and donnt use nested sprites with P2 physics anymore. Link to comment Share on other sites More sharing options...
Recommended Posts