fire once for each layout change?

0 favourites
  • 3 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • Hi,

    I have two layouts, one for landscape and one for portrait (for mobile).

    They both have the same event sheet attached.

    However, when the player switches from one to the other, the layouts objects are destroyed, and I lose game state (as I was storing the game state in the objects parameters.

    I need to restore game state on layout switch.

    I tried adding an "on start of layout" event, but this fires if you resize the same layout, so not useful in this case.

    I can see a few ideas:

    1) store the layout state (portrait or landsape) in globals. I try and avoid globals for state where possible as they are difficult to manage in complex conditions.

    2) possibly detach the single event sheet from both layouts, and attatch separate event sheets that do something only once on switching to that layout, then include the main event sheet. However, I dont know what that event might be?

    3) other cunning strategy?

    Thanks!

  • I think you could do this without different layouts.

    Have you tried the fullscreen modes? They allow for the viewport to scale to meet the browsers size

    also there is a system action to set the canvas size

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • thanks for the reply.

    Unfortunately, the letterbox scaling is not appropriate for mobile, as black bars are not acceptable to the customer and it makes the buttons too small, especailly in landscape.

    What is a canvas? I cant find it in the manual.

    I am strugling to understand the difference between window size, viewport size, actuall browser window size, layout size, layer scaling and canvas - I belive its a missing page in the manual.

    Any tips appreciated.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)