InsOp Posted February 26, 2015 Share Posted February 26, 2015 Hello,ive been struggling with the positions of sprites within displayobjectcontainers. Its hard to calculate the absolute position on the screen.Ive been calculating it like this: var sx = attacker.sprite.position.x + attacker.sprite.parent.position.x; var sy = attacker.sprite.position.y + attacker.sprite.parent.position.y; var tx = target.sprite.position.x + target.sprite.parent.position.x; var ty = target.sprite.position.y + target.sprite.parent.position.y;now im shooting lasers (another DOC) from sx|sy to tx|ty and im having a hard time to calculate whether the laser intersects with the target sprite since the positions of everything is pretty much fucked up. Is there a good way to get the "world"-position or "absolute"-position? Quote Link to comment Share on other sites More sharing options...
xerver Posted February 27, 2015 Share Posted February 27, 2015 Have you tried using the worldTransform matrix of the object? InsOp 1 Quote Link to comment Share on other sites More sharing options...
kyptov Posted February 28, 2015 Share Posted February 28, 2015 var sx = attacker.sprite.worldTransform.tx; var sy = attacker.sprite.worldTransform.ty; var tx = target.sprite.worldTransform.tx; var ty = target.sprite.worldTransform.ty; Quote Link to comment Share on other sites More sharing options...
InsOp Posted February 28, 2015 Author Share Posted February 28, 2015 thanks, didnt see this method in the API since it was read-only Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.