How do I preload images to make sprites appear immediately when I create them?

0 favourites
  • 6 posts
From the Asset Store
Elevate your games with our AI Chatbot Integration! Seamlessly connect your Construct 3 projects with GPT-4 for dynamic,
  • Please see this demo project:

    dropbox.com/s/b6g18oaeljp2u0d/PreloadImage.c3p

    There are two layouts - L1 and L2. In both layouts a big sprite is created on start.

    Layout L1 has an instance of this sprite, so when I delete this instance and create a new one, it happens immediately.

    Layout L2 has no instances of this sprite. When I create it, there is a visible delay - you can see a splash of white background before the image appears. This is especially noticeable on mobile, I have an old phone and it shows the white background for about half a second!

    What I don't understand is why preloading the image doesn't make any difference?? It still takes the same long time for the image to appear on layout L2, even though it's already loaded to memory.

    Am I doing something wrong?

    Tagged:

  • This is referred to in the manual as 'jank' and it mentions that what you're doing with placing the object in the layout and destroying it is the best method :

    "Construct is forced to load the object images at the moment of creation, which can cause a momentary pause in the gameplay, or in extreme cases a constant stuttering (also known as "jank"). In order to avoid this, simply place any objects that will be used by the layout in the layout view. If they are not immediately needed then they can be destroyed in a Start of layout event. They will then not exist when the layout starts, but Construct will still have pre-loaded their images, ensuring that they can later be created at runtime without any jank."

    I see what you are saying though, you have pre-loaded the image and in the next layout the image should not be released from memory so should be instant. Maybe that system action you are using to preload does not do the same thing as destroying an object at the start of layout.

  • Yeah, I ended up adding all objects onto the main game layout, and it's turning into a huge mess.. Also this means that lots of unnecessary images are loaded every time (backgrounds which will not be used in this level etc.), and a lot of memory is wasted.

    .

    I think I understand what's happening - this image gets released from memory when switching to another layout, and then it's loaded again.

    Ashley Could you please confirm this is the case? Is there any way to preload images and keep them in memory even after switching to another layout?

    I think MM_Preloader plugin does that, but there is no C3runtime version of it..

  • Is there any way to preload images and keep them in memory even after switching to another layout?

    Yes - place them on the layout, as described.

  • Yes - place them on the layout, as described.

    Ashley I thought the whole point of new "Load images" actions in C3 was to avoid that.

    Is it technically possible to add an option to store images in memory permanently?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley I thought the whole point of new "Load images" actions in C3 was to avoid that.

    No. "Load images" loads images that are currently unloaded. Placing an object in a layout tells Construct "this layout uses this object's images". Those are two different things.

    Is it technically possible to add an option to store images in memory permanently?

    Yes, place it on every layout.

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