object load into memory

0 favourites
  • 6 posts
From the Asset Store
Test and challenge your memory in this amazing Christmas themed memory game!
  • I have a number of sprite objects in my game that have about 30-40 frames.

    Sprite1 (40 frames) 300k

    Sprite2 (35 frames) 240k

    Sprite3 (30 frames) 200k

    Sprite4 (30 frames) 200k

    Sprite5 (30 frames) 200k

    Each of my levels only uses 1 type of sprite object in the layout. However, having those other sprites in the layout and destroying them on start up isn't enough, I believe they are still loaded into memory. I want to avoid this and save as much memory as possible.

    Do I need to delete the instance in the C2 editor? (when you delete the last instance of an object in the layout and it pops up and tells you your object still exists) or should I make different layouts for each sprite type? I'd rather not make different layouts! Since I'd have to copy any changes to the HUD or pause menu...

    EDIT: I tried deleting the last instance.. that doesn't work! what if I had the objects in a dummy layout? that way I don't need to destroy them all the time, and they are only created if I need them? I think there is a bit of jank when loading though. Maybe I can wait for the objects to be loaded since they are loaded OnStartOf Layout?

  • See memory usage in the manual. If there are no instances of an object in the layout view, its images won't be loaded at the start of layout.

  • jobel

    Many of us long term developers do indeed use a dummy layout. Only primary level objects are ever kept on the layout of use. If there is any possibility an object is NOT going to be used on every layout. Then just use a dummy. This tip always comes up whenever a "Best Practices" thread comes up.

  • jayderyu thanks that seems to be the way to go... do you ever experience any jank when creating an object not in the layout?

    I tried it and I can't tell without a lot more in-depth testing. All my loading is done OnStartOfLayout.. I have global variables that determine what kind of sprites the layout will use.. theoretically I could wait to start the level after any jank, but I'd rather not add more transition time between layouts.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • jayderyu This now all seems moot looking into NW.js (which I'm using). It seems to cache each layout in memory negating any benefit from having a dummy layout.

  • Yup, it certainly does cache everything you've used on your layouts. So despite "per layout" design of C2, the 3rd party wrappers (Chromium) pretty much load everything and holds it in memory as a cache despite C2's active layout having functional garbage collection.

    I didn't even realize that until I investigated it further after Klang's developer mentioned 4GB of memory usage crashing 32 bit OS.

    Because of this, you can forget about making bigger games for mobiles with C2, even if mobile hardware can handle the logic & GPU power is enough, most devices have 1GB memory only, which they have to share with the OS & background apps.

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