Jump to content

Real body x position (P2)


zajca
 Share

Recommended Posts

I want on collision calculate positions of player and items that collides and evaluate if items is in certain bounds in relation to player.

 

But I'm not sure what is real position of body, not sprite image.

 

I was going through documentation and objects and found these coordinates:

player.x,player.sprite.x,player.sprite.body.x,player.data.position[0],player.data.position[1],player.sprite.position.x,player.sprite._bounds.x,player.sprite._bounds.left,player.sprite._bounds.right,player.sprite._bounds.width

but the values doesn't make sense to me:

133.02244186401367133133.02244186401367-6.651122093200684-40.4560775756835941330000

player has dimensions 296x135px

and body starts ~18px from sprite left side and ends ~40px from right side.

anchor is set to 0,0

 

x looks like center of body (sprite was moved almost to border) 

296-58 = 238/2 = 119 + 18 = 137

 

also in 2.4 _bounds are not calculated and I'm getting 0 all the time.

 

how can I calculate x position on start of body and end of body, to be able detect if collision like on the picture?

 

//EDIT: also items are rotating and colliding, so I need real x body position.

post-15579-0-82049600-1440401787.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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