Is there any way to ensure or a trick to do this?
Forum
![>](img/i_next.png)
![>](img/icons/cs2d.png)
![>](img/i_next.png)
![>](img/i_next.png)
Is there any way to change image order?
6 replies![To the start](img/i_first.png)
![Previous](img/i_prev.png)
![Next](img/i_next.png)
![To the start](img/i_last.png)
Is there any way to ensure or a trick to do this?
![user](img/i_friend.png)
![user](img/i_friend.png)
![cs2d lua cmd](img/i_codehelp.png)
![user](img/i_friend.png)
@
![user](img/i_friend.png)
@
![user](img/i_friend.png)
If you know what sprites the images are going to use you could create them all beforehand in the right order and hide them (either set alpha to 0 or move them outside the visible area) until they are needed.
If you don't know which sprites are going to be used, you could still create the images beforehand but put all possible sprites in one big texture atlas and use multi frame sprites and change the frames as required with
![cs2d lua cmd](img/i_codehelp.png)
The last resort would be to destroy and re-create images in the right order whenever you need to change the order. Note that this is quite expensive and traffic-heavy and will certainly lead to lags when you have many images.
![user](img/i_friend.png)
@
Cure Pikachu: How bad will be the performance
when creating
image on every frame (or I can say, for every 20ms)? I actually want to implement image caching, but it seems impossible because the image order is undefined.
![user](img/i_friend.png)
when creating
![cs2d lua cmd](img/i_codehelp.png)
Something like this should be avoided if possible. It might work well for one image without big performance issues but it will cause an ridiculous amount of network traffic over time.
![user](img/i_friend.png)
![user](img/i_friend.png)
If you don't know which sprites are going to be used, you could still create the images beforehand but put all possible sprites in one big texture atlas and use multi frame sprites and change the frames as required with
imageframe.
![cs2d lua cmd](img/i_codehelp.png)
Just a note, this method doesn't work in my situation. The script only calls my callback function which tells them "do x with this additional useful data. I don't care how and which function do you use to do x". In this case, the script calls my callback and tell it "draw this image with this information (scale, rotatation, position)". Also pre-rendering the animation requires too much work on my side, because the data is stored in a instruction-like system, which can loop from beginning or jump directly. To make it simple, I only have animation data sequence and image information to be used.
Out of curiosity, how bad the performance if
![cs2d lua cmd](img/i_codehelp.png)
![cs2d lua cmd](img/i_codehelp.png)
![cs2d lua cmd](img/i_codehelp.png)
![cs2d lua cmd](img/i_codehelp.png)
![cs2d lua cmd](img/i_codehelp.png)
I highly doubt that these 4 together are 4 times slower than creating a new image. I would assume that they are only slightly slower (if at all) because creating a new image is more expensive than changing an existing one.
![To the start](img/i_first.png)
![Previous](img/i_prev.png)
![Next](img/i_next.png)
![To the start](img/i_last.png)