Jump to content

How to calculate absolute world x/y without using world xy property?


ForgeableSum
 Share

Recommended Posts

Quote

It's just dawned on my that may be where the miscalculation is, because those arbitrary movements assume 0 rotations. But how can I calculate the x/y, taking all the world transforms into account?

Nevermind what I said there. The muzzle flash sprites are in fact in the correct positions, it's only the bullet x/y world positions that I am calculating wrong. 

Link to comment
Share on other sites

6 hours ago, TickleMeElmo said:

Oh, for fucks sake I'm an idiot, Phaser is built upon pixi, just use .worldTransform.tx, and .worldTransform.ty. just remember to use these after a render loop otherwise they haven't updated

hmm, I actually tried that when I discovered the post. If I use the values as they are (for example worldTransform.tx on the muzzleFlashSprite), the coordinates are all at the top of the map (no where near the units). 

Link to comment
Share on other sites

42 minutes ago, TickleMeElmo said:

top left corner right? just use worldTransform.tx + camera.x, worldTransform.ty + camera.y

I'm afraid that puts me back at square one. Same results as using the .world property. the x/y positions are affected by camera movements and results are inconsistent (sometimes the bullet doesn't start right on top of the muzzleFlashSprite, possible because of camera movement). 

Link to comment
Share on other sites

1 hour ago, feudalwars said:

I'm afraid that puts me back at square one. Same results as using the .world property. the x/y positions are affected by camera movements and results are inconsistent (sometimes the bullet doesn't start right on top of the muzzleFlashSprite, possible because of camera movement). 

seems like you're also scaling the stage, also add scale into there then

Link to comment
Share on other sites

Okay, I've created an example to prove world x/y do not work:

http://phaser.io/sandbox/edit/qGrKzXHd

In this example, I have 3 sprites: SpriteA, B and C. 

C is child of B and B of A. If you try and make an "x" appear on top of sprite C by adding it to the game world as a sprite at the world x/y of C, the x appears very from the sprite. The only time "x" appears on top of the sprite (using world x/y) is if the child sprite is a direct descendant of the game world (i.e. it is like sprite A and is not the child of another sprite). 

What good then is the world x/y if it doesn't give actual world x/y values? 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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