montego Posted January 11, 2022 Share Posted January 11, 2022 Hi everyone, Hi Ivan, First of all thanks to Ivan for answering all our questios without loosing your mind . What I have is a sprite (ship) with child container (weapon anchor). Now I want to draw a line (laser) from that container to another sprite (foe). The problem is, I cannot get the global coords of the container, but only the local ones. The workaround with getBounds() seems to return local x/y coordinates as well var anchorWeapon = getByName(sprite.children, 'anchorWeapon'); // get the container for the anchorWeapon var bounds = anchorWeapon.getBounds(); // width and height should be 0 laser.points = [bounds.x, bounds.y, foe.x, foe.y]; // in function call: laser.moveTo(laser.points[0], laser.points[1]); laser.lineTo(laser.points[2], laser.points[3]); I tried to make the line a child of the container itself, but then I cannot use the coords of the foe to line to because we are in local context. What would be the best way to solve this? Thanks a heap! Daniel 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.