EVENT ANIMATESPRITES: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
This event can be used to manipulate sprites that are drawn on the screen.  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 ).
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:'''
'''Example of how to use this event:'''

Revision as of 23:01, 23 January 2009

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.

See also gettspr and settspr