How exactly are assets loaded?

Get help using Construct 2

Post » Sun Apr 01, 2012 12:04 am

@Ashley (to get your attention because I need a technical "description"). I'm sorry if this information is somewhere already, but I can't find it.

I finished an education application, it has around 50mb of images. On web preview it works perfectly, in phoneGap it crashes (see my question here: http://stackoverflow.com/questions/9960100/phonegap-android-with-relatively-large-html5-application-hangs-or-crashes).

So, how exactly are assets loaded into construct? Becuase if they are forced into ram at the beginning this will limit a lot the ability to develop for mobile.

If someone has any information it would be greatly appreciate it.
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Sun Apr 01, 2012 12:32 am

Non technical description: see that little blue bar underneath the html5 logo at the beginning of the game? Thats the preloader.
Loading assets separately is on the todo list.
Until then, 50megs is just too much, even for pc's imo.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Sun Apr 01, 2012 12:50 am

Well, right now it will just load all the game images on startup, so the phone will probably also decompress them to bitmap in memory. We have improving resource management on our todo list but it's quite complicated. Even then it will probably only reduce it to per-layout images, so you'll still have to make sure one layout can fit in phone memory. 50mb sounds kinda big even considering that, since that's probably the compressed size you're measuring. Decompressed it could be 300mb+, so one layout could still push the phone memory to the limit. Why is your game so large? Do you have long animations or something? It is of course best to scale down games for weaker mobile hardware and test regularly from the start so you know when you're hitting limits rather than getting a nasty surprise at the end.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sun Apr 01, 2012 1:26 am

Is it possible to override or modify C2 loading everything on start with the plugin sdk?

The game I'm working on a will be ~100MB, but each layout has few assets <15MB.
B
17
S
6
G
6
Posts: 113
Reputation: 4,161

Post » Sun Apr 01, 2012 9:03 am

One hackish solution for the moment is to implement a "lazy-load". Use white Sprites of the right size in your game, and, when the user is doing something that means is going to change layout, use the Behavior to inject new images in those Sprites (you can find that behavior in the "Plugins" section of the forum).
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Sun Apr 01, 2012 9:12 am

@Pode I was actually looking at yours and at the loadURL plugins to solve my problems. Basically I don't need to have 50mb of images at runtime since the application is procedurally generated at runtime showing only ONE image (60kb) out of the thousands I have so your plugin could be a saver. Now my only problem is to understand from where c2 loads images locally, it looks like image.png from preview and images/image.png from "compiled".

Also is it possible to build the image name from variables?
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Sun Apr 01, 2012 9:18 am

@0plus1 : I know that the loadURL (which isn't mine) plugin has a once where he doesn't update the graphical view when it fetches an image, but some time after...
If you want to use my behavior, you can load images from the exported image folder. Or you can place directly your own imagefiles in a folder next to it.

If you use a global var "image_to_load", and you exported the game "MyGame", say, to dropbox, you need to fill your var like this :
[quote]
image_to_load = 'http://dl.dropbox.com/u/YOURADRESS/MyGame/images/' & 'name_of_your_image.png'
[/quote]
You can then pass 'image_to_load' as the adress to my behavior.
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Sun Apr 01, 2012 9:25 am

@Pode Ok I see, I need something relative though, I'm experimenting with assets loading as I would like something relative in order to have it load from phonegap.

Like image_to_load = 'images/image.png' I'll let you know.
You are a life saver!0plus12012-04-01 09:27:45
B
29
S
9
G
6
Posts: 525
Reputation: 8,294


Return to How do I....?

Who is online

Users browsing this forum: Khamsou, Yahoo [Bot] and 19 guests