How do I get a url based image gallery to work?

Get help using Construct 2

Post » Fri May 27, 2016 9:58 am

I've created a simple gallery that loads an image into instances of an image placeholder sprite on creation of the sprite.

I use a random image url with a cache breaking value on the end to ensure a fresh image every time.

Problem is that when the image placeholder sprite is created, the call to load the image from the url reloads ALL the placeholders rather than just the one just created.

Here's a demo capx:
https://drive.google.com/file/d/0BxrnHlX5UrYYTk5yRXJNU2V3RTg/view?usp=sharing

This might be a bug, but it's more likely me doing it wrong.

Please someone point me in the right direction!
B
7
S
2
Posts: 23
Reputation: 531

Post » Fri May 27, 2016 10:38 am

I've now realised that this behaviour is by design. The sprite object instances all share the same image source, so if I change it, it changes on all instances.

So my question is now: how do I load different images into an undetermined number of sprite object instances? Or is this the wrong approach?
B
7
S
2
Posts: 23
Reputation: 531

Post » Fri May 27, 2016 10:54 am

I found another way to do it. I used the paster plugin instead.

https://www.scirra.com/forum/plugin-paster_t88750

Paster allows you to create instances of an object with unique image sources.

Big thanks to R0J0hound!
B
7
S
2
Posts: 23
Reputation: 531

Post » Fri May 27, 2016 3:21 pm

There is a "vanilla" way to do it, but it's rather silly. You create a sprite with multiple "placeholder" animation frames. Each instance of the sprite use a particular animation frame, so when you load from URL, it only seems to change a single sprite.
B
75
S
31
G
27
Posts: 1,000
Reputation: 20,735

Post » Fri May 27, 2016 3:34 pm

Thanks, always good to have options!
B
7
S
2
Posts: 23
Reputation: 531


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests