EVENT ANIMATESPRITES: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 21: | Line 21: | ||
The second block of code removes transparency from the player's tsprite, so that when the player is in F7 view mode, the player sprite will appear solid. This effect cannot be achieved by setting the cstat of the player sprite directly. Note that the code will only effect the player sprite, because only the player sprite has had 16 added to its mdflags member. | The second block of code removes transparency from the player's tsprite, so that when the player is in F7 view mode, the player sprite will appear solid. This effect cannot be achieved by setting the cstat of the player sprite directly. Note that the code will only effect the player sprite, because only the player sprite has had 16 added to its mdflags member. | ||
Keep in mind that sprites with a cstat of 32768 won't run this event, since that cstat won't just turn the sprite invisible but actually will stop the game from rendering the sprite. For the same reason, setting to tsprcstat to 32768 will have no effect. | |||
See also [[gettspr]] and [[settspr]] | See also [[gettspr]] and [[settspr]] | ||
[[Category:Events]] | [[Category:Events]] |
Revision as of 01:21, 20 August 2011
EVENT_ANIMATESPRITES is a Game Event.
This event can be used to manipulate sprites that are drawn on the screen (for example the color of a sprite when Nightvision Googles are used). It is triggered only by drawn sprites when 16 has been added to the mdflags member of the corresponding sprite in the game world. Drawn sprites are accessed through the tsprite array, which has its own members separate from the regular actor array. Members of the tsprite array are similar to members of the regular sprite array, but they begin with 'tspr' (E.g., xrepeat becomes tsprxrepeat ).
Example of how to use this event:
gamevar TEMP 0 0 actor APLAYER MAXPLAYERHEALTH PSTAND 0 0 getactor[THISACTOR].mdflags TEMP orvar TEMP 16 setactor[THISACTOR].mdflags TEMP // rest of player code
In this first block of code, we add 16 to the mdflags member of the player sprite, so that it will be processed by the ANIMATESPRITES event. Next, is the code for the event:
onevent EVENT_ANIMATESPRITES gettspr[THISACTOR].tsprcstat TEMP ifvarand TEMP 2 xorvar TEMP 2 settspr[THISACTOR].tsprcstat TEMP endevent
The second block of code removes transparency from the player's tsprite, so that when the player is in F7 view mode, the player sprite will appear solid. This effect cannot be achieved by setting the cstat of the player sprite directly. Note that the code will only effect the player sprite, because only the player sprite has had 16 added to its mdflags member.
Keep in mind that sprites with a cstat of 32768 won't run this event, since that cstat won't just turn the sprite invisible but actually will stop the game from rendering the sprite. For the same reason, setting to tsprcstat to 32768 will have no effect.