Jump to content

DisplayObject.world X and Y values acting strangely


OTG
 Share

Recommended Posts

Hi everyone, recent lurker, first-time poster.

I'm attempting to position an HTML input element based on the world position of a phaser display object. Something very strange is occurring when I log the point to the console.

The sprite's world point is returning 0, 0 but when I expand the point object in the console it's showing values other than 0, 0 (in chrome and safari the X values are the same but the Y vales are different). See attached images.

58923fcf49956_ScreenShot2017-02-01at3_00_47PM.png.bb02780de9da5dedfe303969644ce9d5.png

Chrome: 58923fcfb5a4d_ScreenShot2017-02-01at3_00_54PM.png.4d93dae499c5a445040930b12fd2b2c3.png

Safari: 58924031c8ddc_ScreenShot2017-02-01at3_08_09PM.png.ce51bd11dbdfe9ce29366b23e5d7e60e.png

Any idea what's happening? And why the values are different in Safari and Chrome?

Link to comment
Share on other sites

Instead of logging the whole point object (e.g. "console.log(sprite.position);") try logging the values (e.g. "console.log(sprite.position.x, sprite.position.y);"). This might be an instance of the console displaying a reference to the object; when you expand it, it shows you the current value instead of the value at that time.

I wouldn't worry too much about the values being different in different browsers right now.

Link to comment
Share on other sites

I see. The issue then is that the display object's world point is returning 0,0. The display object is being added as a child to a sprite that's already been added to the world so I'm not sure why it'd be reporting back these values.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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