Spalac Posted June 14, 2015 Share Posted June 14, 2015 Hello, I try to make a shooter game with Phaser 2 but i encounter problems to rotate the player sprite and the player hitbox in the same time ... I simplidied my code to keep only the rotation of player :function create() { game.physics.startSystem(Phaser.Physics.ARCADE); player = game.add.sprite(200, 200, 'player'); game.physics.arcade.enable(player); player.anchor.set(0.5, 0.5);}function update() { // player rotation player.rotation = game.physics.arcade.angleToPointer(player); // hitbox rotation player.body.rotate = game.physics.arcade.angleToPointer(player); // player.body.rotation = game.physics.arcade.angleToPointer(player);}function render() { game.debug.body(player, "#9090ff", false);}Result : Init : player_rotate1.jpgAnd when i move the mouse : player_rotate2.jpgAnd What i try to make : player_rotate3.jpg Second question : Can i change hitbox type into a circle with Arcade library ?I made it with Box2D library :game.physics.box2d.enable(player);player.body.setCircle(14);but i don't want import two librarys ( and i can't rotate the player with this library ) Regards,Spalac Link to comment Share on other sites More sharing options...
rich Posted June 15, 2015 Share Posted June 15, 2015 Arcade Physics works using AABB only. I.e. no rotation. If you need to support rotated hit boxes or circles then you need to use P2 or Box2D. Link to comment Share on other sites More sharing options...
Recommended Posts