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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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