How to center pictures in the middle of the scene ?

Tilte says it all

Best Answers

  • SlickZeroSlickZero Houston, TexasPosts: 2,870
    edited February 2013 Accepted Answer
    Drag 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
  • PixelMetalPixelMetal Posts: 283
    edited February 2013 Accepted Answer
    Actually, 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.
  • sparkaniasparkania Posts: 300
    Accepted Answer
    if 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

  • AportolGamesAportolGames Member Posts: 26
    Drag 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
    Thank you :D

  • PixelMetalPixelMetal Member Posts: 283
    Yeah, that's more or less the same thing put into a global attribute. Is there a reason you're using constrain and not change?
  • AportolGamesAportolGames Member Posts: 26
    Actually, 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.
    Thnx :D
  • AportolGamesAportolGames Member Posts: 26
    if 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
    Thnx :D
Sign In or Register to comment.