How do I create an object on another layout?

0 favourites
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Greetings,

    I'm currently on Layout 1, however I would like to create objects on Layout 2, Layer 3.

    Is it possible to do so? The Create object command doesn't work as I write the layer there only, obviously the program doesn't get the layers of other layouts so my command does nothing.

    Thank you very much

  • One way to do it would be to use global variables..

    Set them to a specific value and on the new layout, if the global variable is that value, create an object..

  • I don't want to change layouts until the object has been created. I'm making a loading screen between levels.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can't create an object on a layout until the layout has loaded.

    You have to do what LittleStain suggested and set a variable to let the layout know it should have that object and then create it in System->On start of layout

  • I didn't have much faith in this option, to create on a different layout and it definitely decreased now.

    Thank you for the answers, I shall make a new layer and make a loading bar there, when the loading bar disappears the layout turns transparent and all the objects can be seen behind.

  • It does work, like I said..

    Example:

  • Thank you for the example, however for it to work as I described you would need to put Create object on Event sheet 1, not Event sheet 2 so that you really create the object from a different layout.

  • why you need to create object on other layout?

    just create it on start of the next layout...... no?

  • Could you please explain what would be the difference?

    Remember that only one layout is active at the same time (only one is visible as well), so any changes made to another layout will have to occur through events..

    In my example, on event sheet one you are telling the program where to create the object on layout 2..

    on the eventsheet connected to layout 2, you are doing the creation itself, based on what happened in layout 1..

    If you'd like it all to happen from the same eventsheet just connect eventsheet one to layout two also and only call the create function if on layout 2 (though I don't see what good that would do you)..

  • My project starts with a menu, when the user presses Play it then randomly generates a huge, i mean huge map, 35k x 35k, which then it populates it with objects.

    In the menu layer it gets some variables saying how the map will be like, it then should go into a loading layout which creates everything since it freezes on mobiles if you do it on the start of the layout. The loading layout then goes into the said map.

    What i was trying to do was to pass the variable from the main menu to the loading layout, the loading layout would create objects on the map layout and would update the loading bar after each object.

    So that is why I needed the ability to create objects on one layout from another.

    I found a workaround with another opaque layer however as stated above.

  • ah ok you want to optimize at maximum performance on mobile phone , since and specially because you have a lot of sprites ??? thats true ?

  • ah ok you want to optimize at maximum performance on mobile phone , since and specially because you have a lot of sprites ??? thats true ?

    Exactly, between 100 and 1k and the same number of images as background (for example leaf beds)

  • yes in this case

    in case of adventure game with a lot of changing background and maybe moving it, a lot of sprite (ennemy and their animation), the player with his different animation .... creating that on start of lyout will lagg the game in start and make it unplayable ....

    remember to preload sound and music , believe me that will optimize performance

    iam testing all optimisation regarding all options and probability .... and i will post on forum "the final optimisation tips" specially for mobile phone (iphone 4 , galaxy s1) because these phone are not expensive and every person have at least these phone ... and specially because games are played by kids

  • It does work, like I said..

    Example:

    Thank you! my objects are created at runtime so replaced globals to array and Boom!

  • That work around, using a layer while stuff is loading to indicate things or hide loading actions, is commonly applied

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