Calculate a global before objects creation

From the Asset Store
Build your own spaceship with the various components in the pack
  • I want to calculate and set some "optimal content width and height" global variables, lets say = x% of the window size, depending on the aspect ratio of the screen. I know how to do that, but I can't find a way to set these globals before my objects are created (since they use these vars with a "on created" event).

    I can solve this with an intro layout where I set the vars and then "go to next layout". This way, however, the setup is broken everytime I press preview (as it runs only the current layout, by default).

    The second option I thought of was to set them inside a js script in "runOnStartup" function. However I can't find how to get the screen width,height from there.

    I guess there must be some event condition that becomes true before objects creation ("on layout start" happens after objects are created)...

    Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you don't want to preview from the intro/loader layout, as a temporary solution you can create a function "InitializeVars" and add it to "On created" events. (probably not all, just the ones that get triggered first). Remove this function call before exporting the game.

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