Changing Drawing Cords to relative to scene

hi all, :slight_smile:
i don’t know if terms “scene” and “screen” are appropriate or not, but i hope they are understandable…

In a scene of say 2500x480px , while the screen(or camera view) is about 640x480…
While drawing any graphics , all cordinates are seemingly relative to that of the screen…
like if I use draw at (10, 10) , it will always stick to (10,10) of the screen…

Is there any way to translate these cords to be relative to that of scene…
like if I use draw at (10,10), it’ll not stick to (10,10) of screen, but (10,10) of scene, hence it will only appear when camera is in that area of the scene…

I hope I was clear…

Anthony

Here’s a few ways you might be able to do it:

scene.graphics.beginFill (10, 10, 100, 100); // draw to scene instead of camera view
var offset = cameraView.globalToLocal (new Point (0, 0));
cameraView.graphics.beginFill (10 + offset.x, 10 + offset.y, 100, 100);

If your hierarchy is simple, you could also determine an offset or scale value by hand, rather than relying on getBounds, localToGlobal, globalToLocal or other functions

There’s also sprite.transform.concatenatedMatrix which may come in handy

1 Like

thanks to you again - as always :slight_smile:

gladly it works now,

Anthony