Jump to content

How make rotate sprite and hitbox in the same time and change hitbox type for circle


Recommended Posts



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.jpg

And when i move the mouse : player_rotate2.jpg

And 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 :


but i don't want import two librarys ( and i can't rotate the player with this library )







Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...