How do I load multiple images?

0 favourites
  • 7 posts
From the Asset Store
500 monsters and creatures images for card games - Set 1
  • Hey there!

    So i read a very good thread on how to load images with file chooser, here https://www.scirra.com/forum/viewtopic.php?f=147&t=125350&p=888793&hilit=file+choose+file+chooser#p888793 -

    However it doesn't cover on how to import multiple images? If i use ''FileChooser.FileURLAt(0)'' with multiple sprites and a global variable, it keeps loading the same image on all the sprites.

    Any solution on how to important multiple images?? Thanks ^_^

    Edit: I want to import the files 1 by 1, not all at once. This way they keep overwriting each others, the first sprite takes the same image as sprite 2, etc. Any idea how i can import 1 file at a time and keep the image?

  • No1 knows how to import images 1 by 1?? Maybe it can't be done??

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • hello, ia am trying same thing... i want to create photo album and so far no results...

  • hello, ia am trying same thing... i want to create photo album and so far no results...

    Yeh same here, i want to be able to import images from time to time, not just 1 or 3 at once but rather 1 by 1..

    But it seems that it cant be done :/ ..

  • I'm working on the same problem for a few days now. Here's what I've tried so far:

    After taking a photo, it's file location is saved to the Dictionary (value), and the file name is used as the "key". Then I save the dictionary as json so that when the app starts the next time, the Dictionary is reloaded from json. This is a "instant" means of accessing data than loading each required item from memory, which requires the subsequent "on loaded" function.

    Next I used a dropdown list. Using "For each key" from the Dictionary, I add an new "item" to the list, which is nothing more than the "key" name for each entry of the Dictionary.

    Next, when you select a new item from the list, the item name can be matched to the Dictionary "key" name, which contains the file location in the Dictionary "value". Once a match is found, the sprite can load the image from the Dictionary "value", which contains the text string of the image file's location.

    I can now load any photo from the dropdown list, but I'm having a problem in automating that process on startup, such that all my photos in the list are loaded to individual sprites.

    Here's a snapshot:

    https://drive.google.com/file/d/0B7uGKf ... sp=sharing

    If this helps and anyone figures out how to load one or more photos into sprites on startup, please post solution here.

    Thanks.

  • hmott

    Indeed it help me alot to understand to synch json data with dictionary object. Well explained.

  • I want to import the files 1 by 1, not all at once. This way they keep overwriting each others, the first sprite takes the same image as sprite 2, etc. Any idea how i can import 1 file at a time and keep the image?

    There are not really any good solution for this i think as its designed this way in C2. The issue have been raised before by other as well. but don't think it will be changed as it doesn't appear to be a problem by Scirra.

    From what I understand and explained simple, it is made this way to reduce download size at the cost of memory in case you actually need to load images during runtime.

    The only way as far as I have figured out to bypass it or workaround it, is to add empty frames to the sprite that need to store the loaded images. And then load each image into its own frame for each sprite.

    So if you want to load 3 images. You sprite need to have 3 frames. then you need to make a counter to make sure that each image is loaded to the correct frame.

    If you need to replace any of these images later on, you have further increase the number of empty frames. Which is where the memory cost starts to add up, because if you for instant want to be able to load 50 images, not meaning 50 images at the same time only, but just load images with the file chooser for a total of 50 times. You have to add 50 empty frames which will be stored in memory even if they are not needed.

    So to make a workaround you need to do the following two things:

    1. You need to know how many images you want to load or allow to be loaded and based on that you have to created empty frames to your sprite that can handle it.

    2. Make a counter that keep track of which frame to load the image too.

    You need to be aware that if you exceed the maximum number of frames and start from frame 0 again then the problem will reappear, so its a trade off between usability and memory use as I see it.

    So the workaround ain't pretty and not effective in anyway, but as far I know the only working one.

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