[r202] Load image from url

Bugs will be moved here once resolved.

Post » Wed Apr 15, 2015 9:02 pm

Problem Description
Sorry for posting yet another one with this load image from url, but might as well get it fixed :)

Think this problem might be somewhat related to: https://www.scirra.com/forum/r200-load-image-from-url-or-nwjs-bug-v2_t128806

The problem is that you can't select individual sprites for loading image from URL, it doesn't respect picking.

This is an overview of the test program:
Image

Three different images which each are linked to a sprite. Each sprite have 3 frames.

Using the code "Load image from URL" will give the following result. Even though it uses a For each and each of the sprite have different images attached.

Image

Using the code "Load image from URL using index" will make the load from url load the correct images.

Image

However using an index to load the images into the correct frames gives some problems. Since this is only a valid way to do it, as long as you know exactly how many images you need. If there are less frames in the sprite it wont work. So causes some issues, one is that load from url is not dynamic, but also picking certain sprites to be used for load from url is completely ignored and the image is loaded for all sprites and controlled by the number of frames in the sprite if you want to load separate images to them.

This also means that if you want to make it dynamic, in the sense that you don't know before hand how many images you need to load. You have to add empty frames to the sprite, which will use memory for no reason.

Attach a Capx
https://dl.dropboxusercontent.com/u/109921357/Load%20image%20from%20url%202/Load_image_from_url.capx

Description of Capx
Just load 3 images into 3 sprite instances

Steps to Reproduce Bug
Just run the program. Disable one of the groups.

Observed Result
Picking of sprites is not used when using Load image from URL. Resulting in use of unnecessary memory if you want to use it dynamically.

Expected Result
That images was load for the picked sprite and not just all of them.

Affected Browsers
Tested with NW.js

Operating System and Service Pack
Windows 7

Construct 2 Version ID
r202
B
44
S
11
G
2
Posts: 1,181
Reputation: 6,816

Post » Tue Apr 21, 2015 1:04 pm

This is by design. To save memory, all Sprites share the same textures for their animations. If you load an image in to frame 0 of the animation, all instances showing that frame will be affected. The method of switching animation frame then loading an image is the recommended workaround.
Scirra Founder
B
381
S
222
G
84
Posts: 23,975
Reputation: 189,160

Post » Tue Apr 21, 2015 2:51 pm

I can understand your point in that. However that argument only stands I think, if you know how many images you need. Meaning you are creating a non dynamic solution.

I did a small test.
Test 1:
3 instances all 256x256 with 3 frames, so each of them can load there own image.

Test 2:
3 individual objects all 256x256 with 1 frame each.

In both cases I tested them with a minimum amount of required frames. And if they should be able to hold 30 images each, the frames are just duplicates of the first frame without any images stored in them in this case.

The program looks like this, and the code for each test.
Image

Each run I kept an eye on the memory used in Windows system management and noted the peak memory used in a 300 second period.

Image
The combined memory use is calculated with the peak memory.

In both cases whether you use 3 instances or individual objects, the save of memory is only true if you know before hand how many images you need. The empty frames will use memory which is expected.
So in either case the most effective way of doing it as I see it, would be to only have the frames that your program actually need and not just a fixed amount.

But since that is not possible in C2 meaning you can't add frames as you need them, you are bound to waste a lot of memory if you do not know before hand whether 3 images would be enough or 30 images. You have to add at least the maximum amount of possible empty frames that you might need, and therefore could waste memory depending on the sizes etc.
B
44
S
11
G
2
Posts: 1,181
Reputation: 6,816

Post » Tue Apr 21, 2015 5:20 pm

Yeah, but dynamically adding frames is a feature request, not a bug.
Scirra Founder
B
381
S
222
G
84
Posts: 23,975
Reputation: 189,160

Post » Tue Apr 21, 2015 5:39 pm

Ok fair enough, thanks for the reply anyway
B
44
S
11
G
2
Posts: 1,181
Reputation: 6,816


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest