Jump to content

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


Spalac
 Share

Recommended Posts

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

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
 

post-15029-0-65362400-1434285040.jpg

post-15029-0-45375000-1434285044.jpg

post-15029-0-03246700-1434285047.jpg

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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