How do I sync up two different tween transitions?

Hectoris919Hectoris919 Posts: 3Member

I am trying to make a sprite seem to be stationary while the borderless window it is in is being moved around with tween transitions in code. I just can't seem to make the window and sprite move at the same time - It looks jittery when both the window and the sprite move
The window seems to move first, then the sprite.

I've also tried not using transitions by first setting the window position, then setting the position of the sprite, but the sprite is always delayed when it changes position.

Anybody know how to make this work in an efficient manner?

NOTE:
I would prefer to use transitions, but if worse comes to worst, I'll resort to eliminating transitions from this part of my project.

Example:
The red box is the sprite and the grey box is the window. Also, yes I am aware that the window in these images are bordered. I just drew them like that to make the idea that I am trying to convey clearer

Before transitions:

After transitions:
(The red box is moved in the opposite direction while the window moves into the upper left corner of the screen)

Answers

  • MegalomaniakMegalomaniak Posts: 2,738Admin

    You'd probably need to use the OS class to fetch the window location and size to keep track of it then have a top node others are parented to that you move in accordance with the window position and size and what have you.

    https://docs.godotengine.org/en/stable/classes/class_os.html

  • Hectoris919Hectoris919 Posts: 3Member

    @Megalomaniak said:
    You'd probably need to use the OS class to fetch the window location and size to keep track of it then have a top node others are parented to that you move in accordance with the window position and size and what have you.

    https://docs.godotengine.org/en/stable/classes/class_os.html

    I think that might work if I were trying to change the position of the sprite in real time. However, I am trying to make this a scripted event. Both the window and the sprite need to move at the same time.

    As I mentioned in my question though, the one of the problems with moving w/o transitions is that the window always seems to move first, then the sprite changes its position a second later, regardless the order of execution in the code.

  • MegalomaniakMegalomaniak Posts: 2,738Admin
    edited August 1

    Well the window position is handled by the OS and not the engine.

    edit: or is it a custom window within your game?

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file