loopindex load image

0 favourites
  • 6 posts
  • I have a for loop and calling "Load Image from URL" with loopindex("levelCount") & "-2.jpg" into a created object.

    All the images have been imported into the project as Files

    The loop works fine but for some reason only the last image is being pulled out and so all images are the same, whereas they should all be different.

    Current outcome:

    Loop first pass pulls 3-2.jpg

    Loop second pass pulls 3-2.jpg

    Loop third 3-2.jpg

    Expected outcome:

    Loop first pass should pull 1-2.jpg

    Loop second pass should pull 2-2.jpg

    Loop third 3-2.jpg

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • All instances of Sprite share the same texture of the same frame in the same animation.

  • Its on purpose that it works like that, even though it makes little sense that it does. The only way to work around it is to add the number of frames you need before hand. So if you need a maximum of 50 images to be loaded you have to add 50 empty frames to your sprite.

    When you load the image you have to increase the frame number each time, otherwise it will just overwrite the image regardless of you loading a new image. Also if you need to store images in different sprites (instances) you also have to do this workaround, as the image is loaded for all sprites of that object type, as picking is ignored when using "Load image from url"

    So regardless of what you do, if you are not sure how many images you need you are going to waste memory or limiting you program.

  • Perhaps I need to add the jpgs as animation frames first as they are currently all separate files loading into the created object.

  • If you need X amount of images, you might as well add them before hand rather than using Load from Url as you need to add the frames anyway, so performance wise you wont benefit from using it "Load image from URL" or at least not a lot. If that is was you are trying to achieve by using it.

  • Not sure I'm tackling this the right way.

    I thought that loading in a jpeg when required would make it quicker than trying to load in 100 at the beginning.

    If I put the 100 images within animation frames would they all need to load before any could be used.

    Basically which would take up less resources

    1. Load from uri jpgs within files folder

    2. Add all images as animation frames within one sprite

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