khleug35 Posted September 26, 2017 Share Posted September 26, 2017 I would like to create some object follow the player movement , this situation like to call game.debug.body(player); method.......... the green square follow/pin the player any idea??? THX Link to comment Share on other sites More sharing options...
samid737 Posted September 26, 2017 Share Posted September 26, 2017 you can use game.physics.arcade.moveToObject() to take care of that. An applied example : If you want one object to always be positioned relative to another object, you can use addChild() to add one sprite as a child of the parent. Link to comment Share on other sites More sharing options...
khleug35 Posted September 26, 2017 Author Share Posted September 26, 2017 1 hour ago, samid737 said: you can use game.physics.arcade.moveToObject() to take care of that. An applied example : If you want one object to always be positioned relative to another object, you can use addChild() to add one sprite as a child of the parent. THX finally, I use addChild() to add the player sprite, like this , I make the graphics's element follow the user graphics = game.add.graphics(0, 0); game.physics.arcade.enable(graphics); graphics.beginFill(0xFF0000, 1); player.addChild(graphics.drawCircle(0, 0, 30)); but when I move the player right left, the graphics's element position will change....... the graphics's element is leave the player body, how to fix it to center, thx I think that the scale problem is make it happen the problem............. if (faceRight == true) { player.scale.x *= -1; player.anchor.x = 0.5; player.x = player.x - 10; faceRight = false; faceLeft = true; bullet_direction = 'right'; } } and player.body.velocity.x = -250; if (faceLeft == true) { player.scale.x *= -1; player.anchor.x = 0.5; faceLeft = false; faceRight = true; bullet_direction = 'left'; } Link to comment Share on other sites More sharing options...
samid737 Posted September 26, 2017 Share Posted September 26, 2017 you can use anchors to center the circle at the player position,: Phaser example. Link to comment Share on other sites More sharing options...
khleug35 Posted September 26, 2017 Author Share Posted September 26, 2017 2 hours ago, samid737 said: you can use anchors to center the circle at the player position,: Phaser example. OH!!!!!!Thanks It work for me!!!!!!!!!!! Thanks!! samid737!!!!!!!!!! Thx for your link!!!! My problem is solved!!!!!! Link to comment Share on other sites More sharing options...
Recommended Posts