Multi-Resolution Game Development With GameBuilder Studio Check it out!
NEW Version 0.9.7 has arrived! New Blazing Fast Particle Engine & More Game Actions. Check it out
Override a data container Property when on smaller device?
  • Not sure if it's posible to re-position the players starting position when the game checks for a smaller screen as the stage is originally 1920X1080 and is checking for when the device has 1280X720

    I set up a Data Container on the main players character and have the Properties, startingPositionX and startingPositionY.

    Then set up a Rules Component that checks for When the game 
    game.Screen.resolutionX < 1280 
    game.Screen.resolutionY < 721
    game.Screen.resolutionX > 960
    game.Screen.resolutionY > 640

    Trigger a ChangeProperty action
    @Renderer.scale = Type Point X .67 Y .67

    Trigger a ChangeProperty action
    @Properties.startingPositionX = 600

    Trigger a ChangeProperty action 
    @Properties.startingPositionY = 465

    This successfully scales down the character but nothing seems to be able to change the startingPositionX and startingPositionY properties in the data container on the player. This is just one approach, the startingPosition properties seem un-affectable?

    Anyone else had any luck with this?


    *I've had no problems with repositioning backgrounds and other entities as they haven't the startingPositionX/Y properties.

  • 12 Comments sorted by
  • @BenFromOregon, "startingPositionX" is a custom property correct? This should be able to be overridden. Make sure to check the path to the property and the syntax used to make sure there is no error when trying to change the property with a Set property action. 
  • @Lavon yes it is  a custom property on the player character, I created a Data/Properties Container just like in the Hungry Hero game which has the 3 properties ( startingPositionX, startingPositionY, lastPositionY) set at different integers. 

    I cannot seem to find anything called Set property, I only see and have tried Change Property and Constrain Property in various ways  just to see if I get a change when deploying to a device which is 1280X720.
    It should work as I mentioned above in this thread, I can get the character's scale to change.

    I checked the pathway also under the condition of the Rules Component that checks for When 
    game.Screen.resolutionX < 1280 
    game.Screen.resolutionY < 721
    game.Screen.resolutionX > 960
    game.Screen.resolutionY > 640

    Trigger a ChangeProperty action
    @Properties.startingPositionX = 600


    The @Properties.startingPositionX is pathway achieved by clicking the ChangeProperty action then in the first field, BirdRed, then Properties, then startingPositionX
    So all the syntax and spelling should be right

    I have to replace a lot of characters with higher resolution images via a new sprite sheet, maybe when I re-create everything  something will show up.
  • @BenFromOregon it should be "Game.Screen.resolutionX" with a capital "G" and yes just use a Change Property action.
  • @Lavon I meant to type Game.Screen.resolutionX with a Capital "G" on this post, in the GBs editor it is/was  Game.Screen.resolutionX, and I used a Change Property action. I attempted again with no luck, and again tested to recognize the smaller screen on device with a Rules Component and Change Property to change characters' scale and this remains successful . I will rebuild with a new sprite sheet(higher resolution to be able to scale down for smaller devices) and see if I can find out why this change property action is not working on a Data/Properties Container property being a starting position of a character.
  • @BenFromOregon Display the value of Game.Screen.resolutionX using a text renderer or output it to the console using the Log action to see what the value of it is while testing to make sure that you are expecting the correct values.
  • @Lavon I set up a text renderer, added a rules component with a change property action @Renderer.text =Type reference #Game.Screen.screenResolutionX and when launched in the editor with game screen size of w:1920 h:1080 and it displayed the following:
    image

    when I deployed to a device of 1280X720 (MotoG) the text renderer display is 1196.


    I noticed some UI components which have logic using a property such as startingPositionX and they "fly in" to this, that they also can scale down on a device but the position is unaffected. I shall keep digging . . .
  • @Lavon additionally I tried having a property named startingXPosition rather than startingPositionX and the naming made no difference in effect as far as being able to override it.
  • @BenFromOregon the resolutionX is the resolution of the entire screen so on the desktop it will be the full screen res. 

    So when you deployed to the MotoG device it is reporting a different resolution than expected correct? Then your action to override the startingPositionX property is never actually being triggered right?
  • When i deploy to Moto G it is reporting 1196 when I figured it should report 1280 which is the Moto G resolution.
    However, I have also tested overriding the scale and positioning (using starting position properties) on some UI elements (on Pause screen and Game Over screen) where the override properties are succesfully triggering on the moto G.
    It's a bit odd, i've recreated everything, an when the player animates from off screen when the GAME_STARTED the override remains unsuccessful.
  • @Lavon  I found a way. (posting this for anyone else ever encountering this challenge)

    If you ever have a player which enters the stage from off-screen when the game starts and you are having this character move on-screen to a Property which you set up for example, a startingPositionX and a startingPositionY (previously set up with a Data/Property component.) AND you want this character to end up at a different startingPositionX and startingPositionY coordinate when the game is being played on a smaller device, here is what I found. . .

    [Originally I built on 1920X1080 and testing the scaling and re-positioning on a device of 1280X720.]

    The original Custom Properties on the main character move onto the screen to were:
    startingPositionX = 950
    startingPositionY = 690

    To get the first main player character's startingPositionX and startingPositionY to be adjusted I set-up a  Rules Component that checks for When 
    Game.Screen.resolutionX < 1280 
    Game.Screen.resolutionY < 721
    Game.Screen.resolutionX > 960
    Game.Screen.resolutionY > 640

    Trigger a ChangeProperty action
    @Properties.startingPositionX = 600
    Trigger a ChangeProperty action
    @Properties.startingPositionY = 465
    Trigger an Interpoplate Action
    set property: @Spatial.position
    From: setPoint(yourX, yourY)  To: setPoint(Self.Properties.startingPositionX , Self.Properties.startingPositionY)
    Then fill out Duration, Delay, etc.


    Otherwise Trigger: an Interpoplate Action
    set property: @Spatial.position
    From: setPoint(yourX, yourY)  To: setPoint(Self.Properties.startingPositionX , Self.Properties.startingPositionY)
    Then fill out Duration, Delay, etc.

    NOTE: I found that if I didn't include the interpolate actions on the new rules component and only had the Change Property actions to change the starting positions properties, the character would not move to the new positions on the smaller device.

    Hope this saves someone some time;)
  • @BenFromOregon I think you might have been thinking that the From values are read when the interpolate action starts to animate? It actually captures the values of the From and To inputs as soon as the action triggers. So if you had a 1 or 2 second delay and you expected the interpolate to pickup new values if the properties changed between the moment the action was triggered and when it actually started animating then it does not work that way. Is that what you ran into?
  • @Lavon I am not so sure what was going on. I got it to work by the approach above. The interesting thing is, there are other characters who also interpolate onto the screen to a position folowing the first character and all I had to do to get them to reposition on a smaller device was this Rules Component: (notice no interpolate actions anywhere)
    Game.Screen.resolutionX < 1280 
    Game.Screen.resolutionY < 721
    Game.Screen.resolutionX > 960
    Game.Screen.resolutionY > 640

    Trigger a ChangeProperty action
    @Properties.startingPositionX = 525
    Trigger a ChangeProperty action
    @Properties.startingPositionY = 460

    and that's all. It was only the first character who enters the screen that wouldn't reposition with this Rules Component. I couldn't find anything in the game to prevent this from working(maybe because the game was starting?); I just happened to try adding on the Interpolate Properties to the same Rules Component in order to get the first player to respond to the Change Properties of startingPositionX and Y.

    All good now.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Tagged