C3 creating objects on start of layout

0 favourites
  • 14 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • I'm not sure if it's a bug, or some new feature I'm missing that I should turn on or pay attention to.

    So, I moved one of my projects from C2 to C3 and I notice that objects I'm creating on start of layout appears after the layout is rendered to the screen.

    This was a small project and the delay was rather short.

    I moved another project, bigger one, with more objects created on the start of the layout and I get an even longer delay.

    This did not happen in C2, with the same project/layouts/events.

    Is there a way to make sure all objects are created on start of layout are fully loaded before the screen is rendered?


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • See the section "dynamically creating objects" in the manual section on the C3 runtime.

    All you need to do is place all objects the layout will use on the layout, and destroy them on startup if you don't need them right away. Then Construct's memory management will handle everything smoothly. This was true in C2 and is still true in C3, except the details about how dynamically loading objects that were not already pre-loaded are different (since it's now done in a way to improve performance and reduce in-game jank).

  • Yikes, that's manually adding dozens of objects to hundreds of layouts.

    Are there any thoughts or future plans to on before layout loads, or is it not feasible?

  • I'm not sure what you mean. This has been the documented way to handle memory management for years, by the way.

  • I remember this feature from when I worked with an old adventure game engine called wintermute.

    You had the on start of layout condition and also on before layout loads.

    Basically it means that the layout won't show until all the logic and objects created in that event are completely done.

    I wouldn't mind handling it myself, but for that I would need an on image load trigger.

    Image url loaded only works if you change the image, but if you create a new object that the image is not loaded into the memory, there is no way to tell when the image has finished loading.

    Currently I just wait like one second and hope it's all loaded (that really depends on the system speed).

  • Or otherwise, make the on object created trigger only after the image is loaded.

  • I don't see how "On before layout loads" helps. The way it works now, if you create an object there it would work identically to how it does now, because it still hasn't pre-loaded the object. You might want to take a look at the system memory management actions.

  • Oh cool, this is new!

    So there is a feature I was missing after all :)

    Thanks, I'll give it a go.

  • I realised with the improved code in the C3 runtime, it's actually straightforward to make the memory management wait for objects created in 'On start of layout' to finish loading their textures before drawing anything. This is less efficient than the normal preload since it's a second step that does not run in parallel to the main loading, but it does mean that anything created in 'On start of layout' is guaranteed to be loaded on the first frame drawn. That should make it easier to manage this type of case. But note there are other reasons to place all the objects a layout will use on that layout - in particular the editor uses knowledge of which objects are placed on layouts together to optimise the arrangements of images on spritesheets and minimise memory use, so it's still a good idea to do that anyway.

  • Ashley can that loading happen across layouts? so if i load an object on the first layout, will it have to be placed in to the next layout as well, or will it remain in memory?

  • Construct's memory management works entirely by the objects placed in a layout.

    When you go to a different layout, Construct will unload everything not placed on the next layout. If you then create the same object in 'On start of layout', it will unload it when changing layout, then immediately load it again in 'On start of layout'. Obviously this is inefficient.

    Even with this change it is still preferable to have everything placed on layouts, so Construct's memory management works well. The change about loading in 'On start of layout' merely avoids drawing a few frames of the game without a newly created object being loaded.

  • I see, thanks for the info, I will get around to it eventually, when I'll find the time to do all the pasting on tons of layouts.

    But it is nice to know that I can apply a quick fix in the meanwhile with a couple of events, even if it means an extra second or two of loading.

  • Hmmm,

    "Memory management now waits for objects created in 'On start of layout' to finish loading before drawing anything"

    So this means, I don't need to do anything?

  • No, it's exactly the thing I explained in my previous post.

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