I have a two characters that oscillate left and right across the screen—from 0 to ScreenWidth().
- Everything works fine until you resize the screen.
- As you can see from the screencast below, it appears that on resize,
ScreenSize()
gets updated to the new window size. - That’s surprising because
Game resolution resize mode
is set to “No changes to the game size” - I expected that
ScreenWidth()
would be the same no matter the window size - Or is there another method to get the “game” size (an invariant that stays the same no matter the size of the window)?
It works fine on initial preview size:
Doesn’t work on resize
Running is controlled by the runDirection
- runDirection=1 => run right
- runDirection=0 => run in place
- runDirection=-1 => run left
The important thing is that changes to runDirection are controlled by where they are on the screen. When they reach the edge of the right screen, they stop. And then when they reach the edge of the left screen, they also stop.
UPDATE: looks like what I wanted was SceneWindowWidth
:
-
ScreenWidth
- the window width? -
SceneWindowWidth
- the width of the scene