ForgeableSum Posted August 17, 2016 Author Share Posted August 17, 2016 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 More sharing options...
ForgeableSum Posted August 18, 2016 Author Share Posted August 18, 2016 I may have discovered a clue: I imagine there must be some way to get these values in pixi. But what the hell are world transforms and what do I do with them? Link to comment Share on other sites More sharing options...
TickleMeElmo Posted August 18, 2016 Share Posted August 18, 2016 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 Link to comment Share on other sites More sharing options...
ForgeableSum Posted August 18, 2016 Author Share Posted August 18, 2016 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 More sharing options...
TickleMeElmo Posted August 18, 2016 Share Posted August 18, 2016 top left corner right? just use worldTransform.tx + camera.x, worldTransform.ty + camera.y Link to comment Share on other sites More sharing options...
ForgeableSum Posted August 18, 2016 Author Share Posted August 18, 2016 Yup Link to comment Share on other sites More sharing options...
ForgeableSum Posted August 18, 2016 Author Share Posted August 18, 2016 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 More sharing options...
TickleMeElmo Posted August 18, 2016 Share Posted August 18, 2016 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 More sharing options...
ForgeableSum Posted August 18, 2016 Author Share Posted August 18, 2016 I'm not scaling the stage or the unit, but I am scaling the bullet by .5. Would that have an effect? If so, how do I account for that when calculating the world position? Link to comment Share on other sites More sharing options...
TickleMeElmo Posted August 18, 2016 Share Posted August 18, 2016 hmm, that's interesting, that shouldn't have big effect. Are you sure that you don't use any Phaser scalemanager or something? Link to comment Share on other sites More sharing options...
ForgeableSum Posted August 18, 2016 Author Share Posted August 18, 2016 Just now, TickleMeElmo said: hmm, that's interesting, that shouldn't have big effect. Are you sure that you don't use any Phaser scalemanager or something? positive. I just checked and the stage world and group scale are all set to 1. Link to comment Share on other sites More sharing options...
ForgeableSum Posted August 19, 2016 Author Share Posted August 19, 2016 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 More sharing options...
ForgeableSum Posted August 19, 2016 Author Share Posted August 19, 2016 And here is a sandbox to show that our humble little get world absolute function doesn't work either (the x is not on top of spriteC): http://phaser.io/sandbox/edit/aaxgLFjM The saga of getting world absolute child sprite positions continues. Link to comment Share on other sites More sharing options...
ForgeableSum Posted August 19, 2016 Author Share Posted August 19, 2016 See here: https://github.com/photonstorm/phaser/issues/2703 Link to comment Share on other sites More sharing options...
Recommended Posts