How to center pictures in the middle of the scene ?
AportolGames
Member Posts: 26
Tilte says it all
Best Answers
-
SlickZero Houston, TexasPosts: 2,870Drag the image on the scene and type it's x and y position in the attributes pane for the image.
The x and y position will be exactly half of your screen size for the game. For example, if the screen size is 1024x768, the exact center of the scene would be... X=512 and Y=384 -
PixelMetal Posts: 283Actually, no, don't do that. That's hard-coded and will only work at that specific screen size.
Do this:
Change attribute self.position.x to game.displaySize.width/2
Change attribute self.position.y to game.displaySize.height/2
OR do this:
Change attribute self.position.x to game.DeviceScreen.Size.width/2
Change attribute self.position.y to game.DeviceScreen.Size.height/2
That will center the actor regardless of screen size. With the addition of Universal Builds you don't want to do ANYTHING based on specific screen coordinates, and if you plan on supporting Android & Windows 8/RT as well, which operate at different resolutions, you don't want to have to deal with remembering to update hard-coded values throughout a project for every platform. -
sparkania Posts: 300if you plan on having that centered image change from time to time.. I wrote this..
http://forums.gamesalad.com/discussion/53001/tip-for-spawning-static-actors#latest
Answers