Get Window Size

Hey, I’m looking to center my camera on the player’s game object as it walks around the game world. In order to do this, I need to know the current size of the window so I can offset the camera’s position by half of the window’s dimensions.

I saw that there’s a callback for listening to window resize messages. Would I implement this in the render script? I am a little confused because I thought that the render script already listens to window resizes, but apparently not by default. A little guidance would be helpful. Thanks.

Edit: I cannot add the camera to the player’s game object because the camera will be changing its target periodically, based on what’s happening in the game.

No the window listener would be implemented by a controller script in your game. This script should know which target to center the camera on and it would use the window size together with the position of the target to position the game object containing the camera.

Note: in the next release we’ll add a window.get_size() function.

3 Likes

Is there a date in mind for the next release?
Edit: Oops, found the release plans right after I posted.

1 Like