Create a sprite with blank frames?

0 favourites
  • 14 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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?



  • 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?

  • 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?

  • 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.

  • 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.)

  • 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

  • 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.

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I still can't get this to work correctly - I'm lodging it as a bug

  • 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 :)

  • Ashley - "you should be able to 'load image from URL' in to each instance separately".

    I can't get this to work either. I can only load one image at a time and the other one will stay black.

    Many Thanks

  • Nathan

    check this post

    its working wit blank frames and load image from url

  • Thanks Peteer. It seems so simple now.

    Here's an updated capx showing how:

  • You're welcome

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)