Jump to content

P2JS and Relatively Positioned Group Children


Sunburned Goose
 Share

Recommended Posts

Is it a known behavior of child sprites that are positioned relative to a positioned parent group have their physics and collision boundaries based on the relative positions in the game world?

var myGroup = game.add.group();myGroup.enableBody = true;myGroup.enableBodyDebug = true;myGroup.physicsBodyType = Phaser.Physics.P2JS;myGroup.x = 1700;myGroup.y = 1700;var mySprite = myGroup.create(0,0,texture);mySprite.x = 0;mySprite.y = 0;mySprite.body.static = true;mySprite.body.clearShapes();mySprite.body.setCircle(mySprite.width / 2);
When I do this, it looks like this, with the texture showing up at 1700,1700 but the boundaries are at 0,0.
 
mDj1DNbl.png
 
a5EK69Cl.png
 
What it should look like is this when I change the coordinates,
 
var myGroup = game.add.group();myGroup.enableBody = true;myGroup.enableBodyDebug = true;myGroup.physicsBodyType = Phaser.Physics.P2JS;myGroup.x = 0;myGroup.y = 0;var mySprite = myGroup.create(0,0,texture);mySprite.x = 1700;mySprite.y = 1700;mySprite.body.static = true;mySprite.body.clearShapes();mySprite.body.setCircle(mySprite.width / 2);
 
lp4psIBl.png
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...