My Universal Binary Overscan Secret Weapon

LovejoyLovejoy Member Posts: 2,078
edited May 2015 in Community Tutorials

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

«13

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    edited May 2015

    Works extremely well!
    Thanks for sharing!

    EDIT: New badge headed your way!

  • ookami007ookami007 Member Posts: 581
    edited May 2015

    Thank you! So, can your formula be used to find the top and bottom of the visible portion of the screen?

  • LovejoyLovejoy Member Posts: 2,078

    @Braydon_SFX said:
    Works extremely well!
    Thanks for sharing!

    EDIT: New badge headed your way!

    Thank you

    @ookami007 said:
    Thank you! So, can your formula be used to find the top and bottom of the visible portion of the screen?

    Yes

    Fortuna Infortuna Forti Una

  • robertkdalerobertkdale USAMember Posts: 912

    Thanks @Lovejoy It works perfectly! :) Thanks for sharing!

    Big Smile Games Play Happy!
    Check out our other GameSalad exclusives.

  • ookami007ookami007 Member Posts: 581

    Excellent! You rock!

    Do you mind if I use this formula in my upcoming class?

  • LovejoyLovejoy Member Posts: 2,078

    @robertkdale said:
    Thanks Lovejoy It works perfectly! :) Thanks for sharing!

    No problem.

    @ookami007 said:
    Excellent! You rock!

    Do you mind if I use this formula in my upcoming class?

    I don't mind at all, i shared it so the whole community has an easier time with their projects.

    Fortuna Infortuna Forti Una

  • ApprowApprow Member Posts: 703

    @Lovejoy Thanks for sharing this great technique! does dis also work like a charm on android devices?

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276

    @Approw I adhoc tested on two devices, and it worked fine.

    Mental Donkey Games
    Website - Facebook - Twitter

  • LovejoyLovejoy Member Posts: 2,078

    @Approw said:
    Lovejoy Thanks for sharing this great technique! does dis also work like a charm on android devices?

    Yes, it works on any device.

    Fortuna Infortuna Forti Una

  • ArmellineArmelline Member, PRO Posts: 5,364

    I fully endorse this method. Always use overscan instead of stretch when it's possible.

  • gingagaminggingagaming FREELANCE GS DEV Member Posts: 1,685

    Thanks for sharing @Lovejoy

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880

    @Lovejoy -- great idea!
    Thanks for posting this!

  • LovejoyLovejoy Member Posts: 2,078

    @Armelline said:
    I fully endorse this method. Always use overscan instead of stretch when it's possible.

    Thank you, means a lot.

    @gingagaming said:
    Thanks for sharing Lovejoy

    Np.

    @RThurman said:
    Lovejoy -- great idea!
    Thanks for posting this!

    Np.

    Im glad everyone finds it useful.

    Fortuna Infortuna Forti Una

  • wanegroupwanegroup Member, PRO Posts: 84

    So nice - great share!!!!

    iOS Apps/Games: Factoids | SkyGunner | TriSideX

  • ookami007ookami007 Member Posts: 581

    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.

  • ookami007ookami007 Member Posts: 581

    Ok... I've tried it multiple ways... looks like Android is having issues with Screen size.

  • LovejoyLovejoy Member Posts: 2,078

    @ookami007 what exactly are you trying to do?

    Fortuna Infortuna Forti Una

  • BBEnkBBEnk Member Posts: 1,764

    I filed a bug on Android not detecting device display size awhile back.

    http://bugs.gamesalad.com/show_bug.cgi?id=384

  • ookami007ookami007 Member Posts: 581

    @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.

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276

    Pu> @ookami007 said:

    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.

    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

  • ookami007ookami007 Member Posts: 581

    @NipaDidIt - I'll try using constrain. Thanks!

  • ookami007ookami007 Member Posts: 581

    @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.

  • LovejoyLovejoy Member Posts: 2,078
    edited May 2015

    @ookami007 said:
    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

  • ookami007ookami007 Member Posts: 581

    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...

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    @ookami007 said:
    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

  • ookami007ookami007 Member Posts: 581

    @AlchimiaStudios - Samsung Galaxy S5.

  • ookami007ookami007 Member Posts: 581

    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.

  • LovejoyLovejoy Member Posts: 2,078

    @ookami007 said:
    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

  • CaptFinnCaptFinn Member Posts: 1,828

    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?

  • MentalDonkeyGamesMentalDonkeyGames Member Posts: 1,276
    edited May 2015

    @FINNBOGG said:
    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

Sign In or Register to comment.