My Universal Binary Overscan Secret Weapon
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
Comments
Works extremely well!
Thanks for sharing!
EDIT: New badge headed your way!
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Thank you! So, can your formula be used to find the top and bottom of the visible portion of the screen?
Thank you
Yes
Fortuna Infortuna Forti Una
Thanks @Lovejoy It works perfectly! Thanks for sharing!
Big Smile Games Play Happy!
Check out our other GameSalad exclusives.
Excellent! You rock!
Do you mind if I use this formula in my upcoming class?
No problem.
I don't mind at all, i shared it so the whole community has an easier time with their projects.
Fortuna Infortuna Forti Una
@Lovejoy Thanks for sharing this great technique! does dis also work like a charm on android devices?
@Approw I adhoc tested on two devices, and it worked fine.
Mental Donkey Games
Website - Facebook - Twitter
Yes, it works on any device.
Fortuna Infortuna Forti Una
I fully endorse this method. Always use overscan instead of stretch when it's possible.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Thanks for sharing @Lovejoy
GAMESALAD DEV FOR HIRE! - www.gingagaming.com
@Lovejoy -- great idea!
Thanks for posting this!
Thank you, means a lot.
Np.
Np.
Im glad everyone finds it useful.
Fortuna Infortuna Forti Una
So nice - great share!!!!
iOS Apps/Games: Factoids | SkyGunner | TriSideX
Quick question... anyone try this on an Android?
It does not seem to be calculating correctly. It seems to work fine in the preview... just not on the android device itself. I get 0.
Ok... I've tried it multiple ways... looks like Android is having issues with Screen size.
@ookami007 what exactly are you trying to do?
Fortuna Infortuna Forti Una
I filed a bug on Android not detecting device display size awhile back.
http://bugs.gamesalad.com/show_bug.cgi?id=384
@Lovejoy - I'm trying to use the formula on an Android device. It looks like @BBEnk already filed a bug report on it.
Instead of getting the actual screen size, I get the game size (in this case iPad 1024x768) when I know the phone resolution is 1920x1024. Consequently, the formula doesn't work.
Pu> @ookami007 said:
Try putting the code in a constrain attribute instead of change attribute.
According to the bug report, that should work.
Mental Donkey Games
Website - Facebook - Twitter
@NipaDidIt - I'll try using constrain. Thanks!
@NipaDidIt - I constrained the screensize height and width to two attributes but I'm still getting the game size, not the attributes of the screen.
Can you take a screenshot of these rules? Because from what this says, you constrained the screen size to an attribute, which it can't really be done so it will show whatever the attribute is. It needs to be the other way around. The attribute changed to the screen size.
Fortuna Infortuna Forti Una
Sorry @Lovejoy I meant the other way around, but I was rushing back to work over lunch.
I'm constraining newheight = screen.size.height and newWidth = screen.size.width
Here's the funny thing.
I have it do a display text with the Height/Width and they are correct (1920x1024)... but, it still looks like it's grabbing the game size (1024x768) for the calculations.
I've pulled all the hair off my head with this... I'm going to have to start pulling hair from more sensitive locations if I can't figure this out...
What device are you testing on?
Follow us: Twitter - Website
@AlchimiaStudios - Samsung Galaxy S5.
So, I have it inside a timer, inside the first scene... and that didn't work... so now, I have it loading a new scene and waiting for a few seconds before going on and it seems to grab it... FINALLY.
So... I guess I'll have two splash screens.
What type of timer did you try? Perhaps try a "every" o second timer and then change scene after 2 seconds. This way you may be able to only use 1 splash screen.
Fortuna Infortuna Forti Una
I dont see the code anywhere in your zip. And when I switch from ipad landscape to iphone 6 landscape. then overscan. the object are off the screen. Or am i not reading this post correctly?
When you switch it to iPhone 6, you need to refresh the preview.
Mental Donkey Games
Website - Facebook - Twitter