How to get the correct position of a scrolled displayObject?

Hello Community,

the followoing scenario:

Imagine a sprite01. This sprite01 has a scrollRect. It also has a child, let’s name it childSprite. When I scroll sprite01 back and forth, the position of childSprite is always identical, as sprite01 itself has not been moved itself (only its displayed sector is).

How can I determine the actual position of childSprite in respect of its scrolled parent sprite(s) WITHOUT determining all scrollRect.x/ scrollRect.y values of ALL of its parents (which actuall can be more than just one scrolled sprite)?

Kind regards
Arnim

Have you looked at localToGlobal/globalToLocal?

Stupid me…

I thaught I did.

I guess, I simply lost the overview in my experimental project.
(sprite.getBounds()., sprite.x, sprite.scrollRect.x, sprite.localToGlobal(…))

So thank you for your hint, Joshua.

Have a nice day.

Kind regards
Arnim

1 Like