Search the Community
Showing results for tags 'toLocalFrame'.
-
It's even kinda funny to ask such a thing, but... Phaser.Physics.P2.Body class has two useful methods to convert points to local/global metrics (docs). For instance it's said [i][b]toWorldFrame(out, localPoint)[/b][/i]/* Transform a local point to world frame. */// out:Array - The vector to store the result in.// localPoint:Array - The input local vector.Ok, fine. I've created a new body with a (0.5,0.5) anchor, moved it to 100:100 px, then i try to find out what will be the (0,0) local body point in global coordinates - obviously the point is 100:100. Let's check: // create a spritevar s = game.add.sprite(0, 0, '');// position at 100:100s.x = s.y = 100;// enable p2 to create the bodygame.physics.p2.enable(s, true);// now try to find out the local 0,0 in world metrics// holds the global point (dunno why, but it's an array rather than Point)var v = [];// relative 0:0 point in global coordinates -- should be 100:100s.body.toWorldFrame(v, [0,0]);// traceconsole.error('result', v);// wtf is this?! O_o// result [-5, -5] Same with the toLocalFrame method. So: - what do these methods calculate?! O.o - are there properly working localToGlobal(p:Point) and globalToLocal(p:Point) methods in phaser or i should implement them myself?
- 6 replies
-
- body
- toLocalFrame
-
(and 3 more)
Tagged with: