Universal Build – Using Overscan

This post was written by Lovejoy

Today i will be sharing with this community one of my little gamesalad secrets. It is a simple yet effective way for repositioning hud actors while using overscan, no matter what device their using. This does not require any extra game attributes made, unlocking actor or any of that mumble jumble. Just one behavior in the actor.

As always, iPad as a base is always my recommended starting point.

This is the equation that makes it all happen:

For Portrait: abs((((game.Screen.Size.Width*1024)/game.Screen.Size.Height)-768)/2)

For Landscape: abs((((game.Screen.Size.Height*1024)/game.Screen.Size.Width)-768)/2)

This equation pretty much finds the space cut off when using overscan. It can be used for more than just the following, but for now this is all ill be going over. And yes i know there is an extra set of brackets in the equation.

So here is how we use it in a project,

Simply place a change attribute behavior in your actor. And change the self position, either x if portrait, or y if landscape.

Working on Portrait Mode:

Since overscan will cut off the sides of the screen, we only need to worry about left and right. So change self.position.X to

For actors on left side of the screen: Self.Position.X+abs((((game.Screen.Size.Width*1024)/game.Screen.Size.Height)-768)/2)

For Actors on right side of the screen: Self.Position.X-abs((((game.Screen.Size.Width*1024)/game.Screen.Size.Height)-768)/2)

Working on Landscape Mode:

Since overscan will cut off the top/bottom of the screen, we only need to worry about top and bottom. So change self.position.Y to

For actors on the top of the screen: self.Position.Y-abs((((game.Screen.Size.Height*1024)/game.Screen.Size.Width)-768)/2)

For actors on bottom of the screen: self.Position.Y+abs((((game.Screen.Size.Height*1024)/game.Screen.Size.Width)-768)/2)

A single change attribute behavior when using overscan. Your project will look excellent in any device, including the thousands of android devices. Below i attached 2 test project files. One for Landscape, and one for portrait. Both in a zipped folder.

Fortuna Infortuna Forti Una