MM_Preloader (layout preloader) (Plugins)

Discuss Scirra's 2D Asset Store

Post » Fri Jun 23, 2017 9:10 am

Overview
- MM_Preloader plugin for C2 & C3 (c2addon & c3addon)
- Capx example download: https://goo.gl/YKyTC7
- Store page: https://www.scirra.com/store/construct2 ... oader-3620

v1.4 update (2017-08-17)
  • Plugin is now compatible with C3 (c3addon added to the pack)
  • Fixed an issue where plugin could have a problem with detecting if an object was already preloaded or not in certain cases

v1.3 update (2017-07-29)
  • Lazy preloading added. Preloads with specified interval. Potential use case: preload next layout while playing the current one

v1.2 update (2017-06-27)
  • Spriter SCML objects compatibility adjustment

What is MM_Preloader?
It's a plugin which handles any type of preloading:
- Layout preloading - preload elements of the next layout to get rid of layout transition lag
- Layout initialization - hook any custom functions to preloader: AJAX, import, multiplayer connection, required calculations, etc.
- Lazy preloading - slowly preload elements of the next layout while playing current layout
- Loader layout - game initial loading screen

Does this plugin just calculate the % or really preload items?
It is a real preloader. With a single action MM_Preloader finds and preloads (loads to memory) all Sprites, Tiled Backgrounds, SpriteFonts, SpriteFonts+, TileMaps and even Spriter objects of the selected layout. You can also preload custom objects or actions.

How do I use it?
Simply add items to the preloader's list and trigger Start action. Plugin will automatically preload and calculate the current preloading progress based on number of added items (and their current preloading state). While it's processing you can use expressions to fetch current state of preloading.

What can I preload?
Really anything. The best feature is the ability to preload assets of layout you are switching to, so it's possible to make a preloader between two layouts (not possible by default in C2).

You can use it on Loader Layout and easily make the initial preloader of your app.

It is also possible to add custom items which means that you can preload sounds, AJAX fetching progress, Ads, multiplayer connection, etc.

Can I make visual preloading?
You can make any visual appearance you want. MM_Preloader does not draw anything, it just preloads and calculates the progress. Based on the current progress you can make any visual custom preloader you need.

Warranty
This plugin has lifetime warranty.
Last edited by BackendFreak on Tue Aug 22, 2017 8:43 pm, edited 3 times in total.
ImageImageImage
B
31
S
19
G
82
Posts: 1,038
Reputation: 46,205

Post » Tue Jun 27, 2017 8:48 pm

Uploaded version 1.2. It has exactly same set of ACEs, there's just a small fix for better compatibility with Spriter's C2 plugin.
ImageImageImage
B
31
S
19
G
82
Posts: 1,038
Reputation: 46,205

Post » Sat Jul 29, 2017 5:20 am

Hi, I have a couple questions if you don't mind.

First, I've noticed for your other plugins you specify in the warranty
This plugin does not rely on any third party libraries (not even jQuery) so it will never get outdated or broken. Lifetime warranty.

Same thing with this preloader?

Publishing on mobile would it need to be added to the wrapper plugins (Cocoon, Intel XDK) as well to get the extra functionality or it works internally so it isn't needed?

Thanks and.. Awesome plugin :)
B
17
S
5
Posts: 10
Reputation: 1,117

Post » Sat Jul 29, 2017 10:35 am

Hi @CrK

MM_Preloader does not use any third party library. It also has a lifetime warranty. I just haven't updated the description yet ;).

No need to add any Github or Cocoon plugins. It works straight away on every platform.

BTW there's v1.3 already available with "Lazy preloading" possibility (preload next layout while playing curent one). I should update the desciption soon with details.
ImageImageImage
B
31
S
19
G
82
Posts: 1,038
Reputation: 46,205

Post » Sat Jul 29, 2017 6:00 pm

@BackendFreak Sounds great :D

And even more flexible with the lazy preloading functionality, but couldn't show some lag on the current layout while preloading and running events at the same time?

Thanks for your time, I'll buy the plugin very soon :)
B
17
S
5
Posts: 10
Reputation: 1,117

Post » Sat Jul 29, 2017 7:51 pm

CrK wrote:@BackendFreak Sounds great :D

And even more flexible with the lazy preloading functionality, but couldn't show some lag on the current layout while preloading and running events at the same time?

Thanks for your time, I'll buy the plugin very soon :)


Lazy preloading works best with many yet small assets, then there's no lag at all. If there are some big assets then the lag can occur indeed. Still there are some workarounds.

Let's say that you have just two big assets and all the rest is quite small. Those two are background layers for instance.
So at the beginning of current layout you can make a short regular preloader for just those two objects (add object to preloader manually), and then start lazy preloading of the next layout while playing the current layout. Preloader does not double load the asset so the backgrounds will be ignored in lazy preloading since they are already in memory).
ImageImageImage
B
31
S
19
G
82
Posts: 1,038
Reputation: 46,205

Post » Sat Jul 29, 2017 9:02 pm

BackendFreak wrote:
Lazy preloading works best with many yet small assets, then there's no lag at all. If there are some big assets then the lag can occur indeed. Still there are some workarounds.

...


I see, interesting workaround and I guess you have to take in account the device memory since if the current layout is still running this means C2 hasn't unloaded the assets in use so both need to fit into memory before switching, right?

One last thing, idk if I'm overthinking but is making a sort of "global" preloader possible? Kind of one preloader layout using MM_Preloader that works dynamically for whatever layout you switch to after it.
So let's say you run "layout 1" > then go to "preloader layout" > it preloads the next "layout 2" and switch to it, then you go again to "preloader layout" this time preloading "layout 3" and so on. Hope it makes sense :|

What I'm wondering is if it's meant to be used making many loader layouts between every regular layouts (like LAYOUT 1 > LOADER 1 > LAYOUT 2 > LOADER 2) that needs to be preloaded or it can be reused in some way.
B
17
S
5
Posts: 10
Reputation: 1,117

Post » Sat Jul 29, 2017 10:44 pm

CrK wrote:One last thing, idk if I'm overthinking but is making a sort of "global" preloader possible? Kind of one preloader layout using MM_Preloader that works dynamically for whatever layout you switch to after it.
So let's say you run "layout 1" > then go to "preloader layout" > it preloads the next "layout 2" and switch to it, then you go again to "preloader layout" this time preloading "layout 3" and so on. Hope it makes sense :|

What I'm wondering is if it's meant to be used making many loader layouts between every regular layouts (like LAYOUT 1 > LOADER 1 > LAYOUT 2 > LOADER 2) that needs to be preloaded or it can be reused in some way.


Yes it is absolutely possible and recommended. There's an action "Add all objects from layout (by name)" which can take a string variable (layout name) as a parameter. With this one you can make a generic preloader layout as you described above.

Actually there are two ways of achieving such generic preloader. One is by making a separate preloader layout. And the second approach is by making a layer dedicated for preloader global. With such layer you just need to set the visuals only once.

I'd recommend the approach with global layer, it will work faster in certain cases. Note that separate layout for preloader will work, but it's a double layout transition so C2 will release assets of Layout1 from the memory and then load all assets from Layout2 with preloader. While with global layer approach common assets for Layout1 and Layout2 will not be released/re-loaded.
ImageImageImage
B
31
S
19
G
82
Posts: 1,038
Reputation: 46,205

Post » Sat Jul 29, 2017 11:48 pm

BackendFreak wrote:Yes it is absolutely possible and recommended. There's an action "Add all objects from layout (by name)" which can take a string variable (layout name) as a parameter. With this one you can make a generic preloader layout as you described above.


Perfect!

BackendFreak wrote:Actually there are two ways of achieving such generic preloader. One is by making a separate preloader layout. And the second approach is by making a layer dedicated for preloader global. With such layer you just need to set the visuals only once.

I'd recommend the approach with global layer, it will work faster in certain cases. Note that separate layout for preloader will work, but it's a double layout transition so C2 will release assets of Layout1 from the memory and then load all assets from Layout2 with preloader. While with global layer approach common assets for Layout1 and Layout2 will not be released/re-loaded.


Mhhh I didn't think it could work as a global layer and it sounds indeed the best way, I just have to play with it a bit to see how to set it this way as I thought it would need a layout with some logic (like: on start of layout > add all objects etc) to make it work.

Seems like this plugin has all pros and no cons at all, so great job!
B
17
S
5
Posts: 10
Reputation: 1,117

Post » Sun Jul 30, 2017 12:20 am

You can make it with global layer and create a separate event sheet "Preloader" with the generic logic which then you simply include in the particular layouts event sheets. No need to write redundant code obviously.

Regular preloader for layout transition is triggered at the end of current layout, not at the start of next layout.

Please see the capx attached to plugin version v1.1. There are some implementation examples.
ImageImageImage
B
31
S
19
G
82
Posts: 1,038
Reputation: 46,205

Next

Return to Scirra Store

Who is online

Users browsing this forum: No registered users and 0 guests