I try to load a base64 format in sprite via array without luck.
In this example i use 2 different images, red and green boxes.
I use an array and add base64 code for each.
What i want is, each sprite to load the image code from array (loopindex).
So basically the result to be 1 red and 1 green boxes.
Can you please help me? Thanks!
Develop games in your browser. Powerful, performant & highly capable.
Sprite instances share the same texture set.
Your example is working as intended, but since you have only a single frame, for multiple instances, only the latest frame loaded is loaded and displayed for all instances.
Add as many frames to your Sprite object as you will have elements in your array (in your example, you need two frames, make sure to set the animation speed to 0).
After the create action, add an action that sets the current animation frame of your sprite to loopindex and then load from the URL.
Yes i test it yesterday but i thought maybe there was a different way with just 1 sprite.
Okay no problem. Thank you! :)