Create a sprite with blank frames?

Get help using Construct 2

Post » Sat Jul 14, 2012 12:58 pm

Hi

I haven't been able to find an answer to this one.

I'd like to create a sprite with 500 blank frames. The images for the frames will all be loaded at run time and will be different depending on what is happening.

I could go into the editor and right click "Add" and then click "new frame" 500 times, but that seems silly.

Is there an easy way to do it? A short cut key to add a new frame? Can I add new frames at run time?

Thanks

Ben
B
4
Posts: 13
Reputation: 376

Post » Sat Jul 14, 2012 3:49 pm

What? Why on earth do you need this? It sounds like a very inefficient thing to do and could waste a lot of memory! I would say don't do it at all. What are you trying to achieve?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Sun Jul 15, 2012 1:06 am

Yes, it does seem a little weird hacky way to do things.

I'm using C2 to display image search results. Ive got everything working with the search request, Ajax loading the results into a dictionary and rendering the results to different visual structures on screen.

The only issue i have is to use the "load from URL" on the sprite object the animation frame needs to already exist. The maximum number of search results is 500 so at the moment it seems like i need to create a sprite with 500 frames to allow me to dynamically load whatever search results come back.

Hacky - yes. But other benefits of C2 make up for this little issue :)

Any ideas how to do it better?
B
4
Posts: 13
Reputation: 376

Post » Sun Jul 15, 2012 7:47 pm

You can do it all with a single animation frame. If you create 10 instances of a sprite with one frame, you should be able to 'load image from URL' in to each instance separately, e.g. using a 'for each' loop. I say 10 because I'm assuming that's how many results fit on screen at once, there's no reason to create more sprites for any results that are not visible.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Mon Jul 16, 2012 12:53 am

Thanks for the reply.

I tried what you suggested first and unfortunately when you do it only the last created sprite keeps its image while each other sprite turns to a black box. You can actually see each individual sprite get its image then turn black as the next instance of the sprite gets its image. It had me scratching my head for a long time and eventually I just gave up with that method!

(I'm rendering the images as a 3D point cloud with server side mip-mapping... so yes, all 500 do fit on the screen at various levels of detail)

No big deal if you can't think of a better way. The memory usage doesn't seem too bad given what I'm doing.

(BTW - I'm really enjoying Construct2, especially the plugin architecture. Just the right level of complexity at each level of the process.)
B
4
Posts: 13
Reputation: 376

Post » Mon Jul 16, 2012 4:52 pm

yeah Ive noticed some wonkyness in the load from url too. A lot of times the image will stay black until you find a way to make c2 redraw it even if the image loaded fine
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Tue Jul 17, 2012 5:07 am

Glad it's not just me :)

How did you force a redraw of the image? I do all sorts of re-positioning and scaling but none of that seemed to make a difference.
B
4
Posts: 13
Reputation: 376

Post » Tue Jul 17, 2012 4:01 pm

try changin the frame or animation then changin it back. I really havent found a good way yet its still a problem Im tryin to figure out too
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Sun Sep 02, 2012 9:47 pm

I still can't get this to work correctly - I'm lodging it as a bug
B
4
Posts: 13
Reputation: 376

Post » Tue Sep 04, 2012 12:18 am

Apparently its by design... all objects and instances of s sprite (and tiled backgrounds) share the same image stack. If you LoadfromURL at runtime in one object they all change.

Back to one sprite with 500 blank frames :)
B
4
Posts: 13
Reputation: 376

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests