A question and a PSA

cbatescbates Member, PRO Posts: 11

So a little story here and a question at the end :)

Here I am, building my first game in GameSalad. I have done tutorials, watched countless videos and have a good basic understanding to move forward.

I create my into, menu system, several levels, power ups, score screens, etc. I figure "Hey I should run a full APK test on my android phone just to see how this works out"

WELLLLLLLL, nothing is positioned correctly, knowing I based the game off iPad portrait I go about troubleshooting and realize that all the tutorials, templates, youtube videos have you use something like (Screen Size/2) to get the middle of the screen. Well what happens when screen size does not equal the size of the scene? Well, nothing works right!

So I am in the delima that I have done a lot of building with (screen size /2) and not (scene size /2), the latter of which fixes the display issues.

So the question is, is this a manual go actor by actor, scene by scene (if actor is unlocked) to change out device.screen.width with scene.width?

And the PSA, make sure you use the right variable in your math calculations lol

Comments

  • pHghostpHghost London, UKMember Posts: 2,342
    edited April 2019

    There is no official way to do this, but there is a way.

    If you will be doing this:

    1) BACK UP your project beforehand.
    2) If you have unlocked actors, you'll have to do those manually, I'm afraid, or you can revert them, if this is the only reason you unlocked them -- to access the scene width.

    This is the way, then, if you are on a Mac (I'm explaining it with width, but the same applies for height):

    PREP:

    1) Create an empty actor called "Scene Measure" and a real attribute called "scene_width"
    2) Drop the actor into every single scene and make it change "scene_width" to the actual width of the scene. You can copy paste that code into each of the unlocked instances of this actor in all scenes.

    EDITING:

    1) Right click your project file and select Show Package Contents.
    2) Navigate to the the 'actors' folder and open all the .XML files in a text editor of your choice.
    3) Find & Replace all instances of keypath="game.devices.screen.size.width" to keypath="game.attributes.idXXXXXX"

    IMPORTANT:

    To find out idXXXXXX, you need to open the object.xml file in the project bundle. Do not edit this. Just find the ID of the "scene_width" attribute you created, it will be something like "id625895."

    The XML will say: <real name="scene_width" id="id625895">0</real>

    If you create the attribute and then check the XML straight away, it should be easy to find the ID at the bottom of the XML, otherwise you can just search for "scene_width" or whatever you named your attribute (I advise against using spaces in attribute names).

  • cbatescbates Member, PRO Posts: 11

    Thanks for the walk through. I feel like this is a case where both fixes will take a large amount of time. I'll probably go through each actor so I don't risk messing up the raw files.

    at least i caught it now vs after finishing the game lol

  • pHghostpHghost London, UKMember Posts: 2,342

    It's one fix per scene if you edit the XML, otherwise all the actors, so that should be a lot quicker. If you do a backup, no need to worry about messing up the raw files. Try it, see if it works, if not, you can always do the manual approach.

  • cbatescbates Member, PRO Posts: 11

    When i go to this step

    2) Navigate to the the 'actors' folder and open all the .XML files in a text editor of your choice.

    I am not able to find the keypath="game.devices.screen.size.width" in any of the xml files i open. Given that i have 176 xml files that might take awhile :)

  • cbatescbates Member, PRO Posts: 11

    Edit. I do see that line in the scene xml files, which i ahve 16 of.

  • pHghostpHghost London, UKMember Posts: 2,342

    It might be the height instead of width. This is the XML equivalent of device.screen.width that you mentioned. Cannot provide more detail since I don't know how the code that is causing you problems is set up. A screenshot might help.

  • bob loblawbob loblaw Member, PRO Posts: 793

    @cbates said:
    So a little story here and a question at the end :)

    Here I am, building my first game in GameSalad. I have done tutorials, watched countless videos and have a good basic understanding to move forward.

    I create my into, menu system, several levels, power ups, score screens, etc. I figure "Hey I should run a full APK test on my android phone just to see how this works out"

    WELLLLLLLL, nothing is positioned correctly, knowing I based the game off iPad portrait I go about troubleshooting and realize that all the tutorials, templates, youtube videos have you use something like (Screen Size/2) to get the middle of the screen. Well what happens when screen size does not equal the size of the scene? Well, nothing works right!

    So I am in the delima that I have done a lot of building with (screen size /2) and not (scene size /2), the latter of which fixes the display issues.

    So the question is, is this a manual go actor by actor, scene by scene (if actor is unlocked) to change out device.screen.width with scene.width?

    And the PSA, make sure you use the right variable in your math calculations lol

    easiest way to do it i find is build on ipad, but work off a minimum longest side of 1665 (to suit the longer samsung phones) for your scene (so 768w by 1665h in portrait).

    your default camera position should be set to cover the middle 1024 pixels of the scene. all your actors should be based around this being the centre of the scene.

    you should have an actor that then detects the size of the device screen on your first scene only, and a second unlocked invisible actor that appears on every scene that adjusts the longest edge length size of the camera to be a size that matches the aspect ratio of the device (ie. if the device is an ipad or legacy iphone, the camera length will be the default 1024. if it’s the highest res samsung 9, or i think also iphone x, the camera longest edge length will be 1665, etc).

    there’s a basic demo i did on here somewhere that i did recently that shows this, as well as repositioning actors for device type. it’s in landscape, but the idea is the same for portrait switching height and width detection and adjustments.

Sign In or Register to comment.