English Does Env_Sprite Equal to Image Function?

2 replies
Goto Page
To the start Previous 1 Next To the start
Up
Masea
Super User
Offline Off
Does cs2d entity env_sprite equal to cs2d lua cmd image? Would using cs2d lua cmd image instead cause any differences like FPS drops or something like that?
Create and design your GUI easy and fast: file cs2d GUI Framework (12) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (25)
01.11.18 09:42:45 pm
Up
DC
Admin
Offline Off
Rendering / FPS
There shouldn't be any significant / noticeable difference. In both cases the images are rendered the same way, causing the same load on the GPU. CPU time also shouldn't be much different (and is probably smaller by magnitudes compared to the GPU time anyway).
tl;dr: no (relevant) difference

Loading / Data
The actual difference is the creation of the image. cs2d entity env_sprite is created once when loading the map. cs2d lua cmd image is created on the fly while the game is running. It also causes network traffic because it's not a static image which is saved in the map file but a dynamically created one. So all clients need to be notified about the image.
Also with cs2d lua cmd image the image itself (the actual pixel data) is loaded at runtime (only once, the first time that image is being used) which can cause a small FPS drop or even a bigger one for large images.
tl;dr: cs2d entity env_sprite is better. Can't cause FPS drops at runtime and doesn't cause additional network traffic.


∗ Best Practice
√ use cs2d entity env_sprite when the image is part of the map. Especially for static images.
√ use cs2d lua cmd image for dynamic images / script controlled images
× using a ton of cs2d entity trigger_delay and cs2d entity env_sprite to fake animations works but is not the most efficient solution. If you want top performance use a single cs2d lua cmd image and a fancy tween like cs2d lua cmd tween_move instead!

p.s.: cs2d entity env_image and cs2d entity env_sprite are also basically equal performance-wise. cs2d entity env_image is just an older variant of cs2d entity env_sprite with less features. It's only still in the game for backward compatibility.
edited 4×, last 01.11.18 09:57:33 pm
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
01.11.18 09:58:17 pm
Up
Masea
Super User
Offline Off
Thank you very much! Got answers for more than I asked.
Create and design your GUI easy and fast: file cs2d GUI Framework (12) | Go deep of the darkness and try your intrepidity: file cs2d Outlast 2 Modification (25)
To the start Previous 1 Next To the start