[NEW INFO] Load image from url (binary data) all sprites same even with different animation frames

0 favourites
  • 1 posts
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • Hello there!

    I have a big issue.

    I'm building a deck editor. I'm using a websites API to load the card images. The owners of the website state that they will ban and blacklist people who download/request too many images per second.

    For this reason I want to create an image cache for these images and only request them if they are not found in the local storage as binary data.

    But the whole thing ends up with a lot of synchronisation issues because of the asynchronous local storage and load image from url (binary data). All cards images always get the same, even with different animation frames set.

    .

    Because the process is complicated I will try to describe the event page as detailed as possible:

    1. On start of layout the online card database version will be checked and compared with the local one. If outdated or missing it will be redownloaded.

    .

    2. The first time the database is downloaded all the data is rearranged in a new json with the card id's being the paths. (Because loaded decklists only contain the cards id)

    .

    3. When a deck is imported the decks card id's are read and for every one of them a sprite instance is spawned with the id as a local variable.

    .

    4. While spawning the sprite (the card) the local storage is searched for a key named like the id of the card. For example 53439220. If it is found then the binary data will be read and the image will be loaded from binary url. (problem: all cards will always get the last image -_-)

    .

    5. If no key with the cards id is found in local storage the sprite will be loaded from image url (from the online api) and this binary data will then be stored as the cards id as a key name to the local storage.

    I tried so many things.

    - Using functions

    - Without functions

    - Setting different animation frames based on object count, loop_index, incrementing

    - Looping through all objects, comparing their id and then setting image from url after Local Storage get is complete

    - Much more that I can not even remember

    .

    Here is what I have so far. I rearranged and changed it a lot so there are many events disabled. But I think you can see what I tried there and what I want to do.

    Any ideas on how this can be solved?

    I just want to be able to load image from url individually for each sprite. =(

    Thank you in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)