quarks Posted June 6, 2015 Share Posted June 6, 2015 What is the point of the "inverted" (in the sense of negated) coordinate conversion methods in the P2 subsystem? Isn't the direction of coordinate system essentially arbitrary, such that multiplying by -1 for conversions in both directions is equivalent to not doing so at all? For example, a sprite with position (100, 200) and velocity (60, -20) in Phaser is to the right of and below the origin and moving to the right and up. Don't you get the same physics whether P2 represents than internally as (5,10) and (3,-1) or as (-5,-10) and (-3,1)? As long as the mirroring is done (or not done) consistently, why does it matter? Link to comment Share on other sites More sharing options...
wayfinder Posted June 6, 2015 Share Posted June 6, 2015 the mpxi/pxmi conversions are precisely what allows you to work that way. Link to comment Share on other sites More sharing options...
quarks Posted June 6, 2015 Author Share Posted June 6, 2015 the mpxi/pxmi conversions are precisely what allows you to work that way. I don't really follow. There are inverted (mpxi/pxmi) and non-inverted (mpx/pxm) versions of these functions. Phaser appears to use the inverted versions internally. Why? And doesn't that force any code that interacts with the Phaser P2 subsystem to use the inverted subsystem as well? Link to comment Share on other sites More sharing options...
wayfinder Posted June 6, 2015 Share Posted June 6, 2015 Yes it does, and the reason is that internally, p2 uses different units than Phaser. The non-inverted versions are used for stuff like circle radii, where the orientation really doesn't matter. But every time you interact with p2 from Phaser you need to apply the mpxi/pxmi unit conversion. Link to comment Share on other sites More sharing options...
quarks Posted June 6, 2015 Author Share Posted June 6, 2015 Yes it does, and the reason is that internally, p2 uses different units than Phaser. The non-inverted versions are used for stuff like circle radii, where the orientation really doesn't matter. But every time you interact with p2 from Phaser you need to apply the mpxi/pxmi unit conversion. Ok, using the non-inverted versions for non-signed values make sense. But I still don't understand why the negative factor is necessary for position/velocity coordinates. What does it matter if Phaser and P2's notions of up/down and left/right are reversed as long as that reversal is consistent? Link to comment Share on other sites More sharing options...
wayfinder Posted June 6, 2015 Share Posted June 6, 2015 That's actually a very good question. I guess you have to do it either in every conversion, or in not a single one—and that's a choice that's been made by the framework, to have it everywhere. I wonder if it were possible to build a, perhaps leaner, but perhaps also more opaque implementation of p2 without any unit conversions whatsoever. Link to comment Share on other sites More sharing options...
Recommended Posts