Class Sprite
Description
The Sprite class is a lua wrapper for LGCK's Sprite object.It allows direct manipulation of the engine data through the member functions.
Directly modifying member variables in a lua object doesn't modify the engine object however. Please use the appropriate member functions for that.
This is a how to get an instance of the Sprite class in an event handlers.
local sprite = getSprite( self );
Members
- int x
- int y
- int aim
- int triggerFlag
- int stateFlag
- int actionMask
- int imageSet
- int imageNo
- int objType
- int id
- string name
- int class
Sprite:activate
- in void
- out void
local sprite = getSprite(self); if sprite:isVisible() then sprite:activeSprite(); end
Sprite:addItem
- in int protoID
- out void
Sprite:attackPlayer
- in void
- out void
Sprite:callEvent
- in int event
- out void
local player = getPlayer(); player:callEvent( EO_DEATH );
For complete list of all available events see callObjEvent() for details.
Sprite:canFall
- in void
- out bool
local s = getSprite( self ); local tmp = copySprite ( s ); local fall = 0; while tmp:canFall() do tmp:move( DOWN ); fall = fall + 1; end tmp:clear(); if fall < 20 then playSound("short fall.ogg"); else playSound("fall.ogg"); end
Sprite:canMove
- in int aim
- out bool
Sprite:changeTo
- in int objType
- out void
Sprite:childCount
- in void
- out int count
Sprite:clear
- in void
- out void
local s = getSprite( self ); local tmp = copySprite ( s ); ... tmp:clear();
Sprite:copy
- in void
- out Sprite
Sprite:frameCount
- in void
- out int
Sprite:freeze
- in void
- out void
Sprite:get
- in mixed key
- out int
The key can also be a constant. The following values are predefined by the engine. The values from 0 to 1000 are considered reserved by the engine.
EXTRA_ORGPROTO EXTRA_ORGX EXTRA_ORGY EXTRA_HP EXTRA_OLDAIM1 EXTRA_OLDAIM2 EXTRA_FALLHEIGHT EXTRA_LIVES EXTRA_ACTIVE EXTRA_BULLETCOUNT EXTRA_OWNER EXTRA_FLAGS EXTRA_PATHDIR EXTRA_PATHPTR EXTRA_ANIMSEQ EXTRA_ANIMPTR EXTRA_ANIMSPEED EXTRA_DEATHINDICATOR EXTRA_AGE EXTRA_TIMEOUT EXTRA_TAGFLAGS EXTRA_INVENTORY
Sprite:getExtra
- in void
- out Extra
Sprite:getHP
- in void
- out int hp
Sprite:getProto
- in void
- out Proto
Sprite:getString
- in void
- out string
Sprite:hasItem
- in int protoID
- out void
Sprite:height
- in void
- out int height
Sprite:hide
- in void
- out void
local player = getPlayer(); player:hide(); if player:isHidden() then Debug:printf("%s is hidden", player.name); end
Sprite:hitTest
- in int aim
- out HitTest
Sprite:isActive
- in void
- out bool active
Sprite:isDead
- in void
- out void
local player = getPlayer(); killPlayer(); if player:isDead() then Debug:printf("player is dead"); end
Sprite:isFrozen
- in void
- out bool
Sprite:isGoal
- in void
- out bool
Sprite:isHidden
- in void
- out void
local player = getPlayer(); Debug:printf("player id= %d; name: %s", player.id, player.name); player:hide(); if player:isHidden() then Debug:printf("%s is hidden", player.name); end
Sprite:isMonster
- in void
- out bool
Sprite:IsPlayer
- in void
- out bool
Sprite:isPlayerThere
- in int aim
- out bool
Sprite:isVisible
- in void
- out bool
Sprite:kill
- in void
- out void
local player = getPlayer(); player:kill(); if player:isDead() then Debug:printf("`%s` is dead", player.name); end
Sprite:land
- in void
- out void
Sprite:map
- in void
- out void
Sprite:markAsGoal
- in void
- out void
Sprite:move
- in int aim
- out void
Sprite:moveBy
- in int tx
- in int ty
- out void
Sprite:moveTo
- in int x
- in int y
- out void
Sprite:objClass
- in void
- out int classId
Sprite:objName
- in void
- out string name of the object
Sprite:objType
- in void
- out int TypeId
Sprite:proto
- in void
- out Proto
Sprite:removeItem
- in int protoID
- out void
Sprite:resetInventory
- in void
- out void
Sprite:set
- in mixed key
- out int
The key can also be a constant. The following values are predefined by the engine. The values from 0 to 1000 are considered reserved by the engine.
EXTRA_ORGPROTO EXTRA_ORGX EXTRA_ORGY EXTRA_HP EXTRA_OLDAIM1 EXTRA_OLDAIM2 EXTRA_FALLHEIGHT EXTRA_LIVES EXTRA_ACTIVE EXTRA_BULLETCOUNT EXTRA_OWNER EXTRA_FLAGS EXTRA_PATHDIR EXTRA_PATHPTR EXTRA_ANIMSEQ EXTRA_ANIMPTR EXTRA_ANIMSPEED EXTRA_DEATHINDICATOR EXTRA_AGE EXTRA_TIMEOUT EXTRA_TAGFLAGS EXTRA_INVENTORY
Sprite:setAim
- in int aim
- out void
Sprite:setAsGoal
- in void
- out void
Sprite:setHP
- in int hp
- out void
Sprite:setImage
- in int imageSet*
- in int imageNo
- out void
local sprite = getSprite(self); sprite:setImage(sprite.imageSet, XOR(sprite.imageNo,1));
in parameter imageSet : optional and can be omitted.
Sprite:setOwner
- in void
- out Sprite owner
Sprite:setState
- in int stateFlag
- in bool flip*
- out int stateFlag
if flip is true the bits are set on otherwise they are cleared. Flip is optional and assumed to be true.
State flag is a combination of the following:
STATE_FALL STATE_DEAD STATE_HIT STATE_JUMP STATE_BEGINNING STATE_FIRING STATE_LOOKUP
Example usage:
local player = getPlayer(); player:setState(STATE_DEAD);
returns the newly modified state flag.
in parameter flip : optional and can be omitted.
Sprite:setTriggerKey
- in int key
- out void
Sprite:show
- in void
- out void
local player = getPlayer(); if player:isHidden() then Debug:printf("%s is hidden", player.name); end player:show();
Sprite:spawn
- in void
- out void
Sprite:stopAnimation
- in void
- out void
local sprite = getSprite( self ); sprite:stopAnimation();
Sprite:testFlags
- in int mask
- out bool result
Sprite:togglePathPlayback
- in bool enable
- out void
Sprite:triggerHitState
- in void
- out void
local player = getPlayer(); player:triggerHitState();
Sprite:tryAnimation
- in int animSeq
- out bool
Sprite:tryPath
- in int path
- in int aim*
- out bool
local player = getPlayer(); player:tryPath(PS_JUMP_LEFT);
in parameter aim : optional and can be omitted.
Sprite:unFreeze
- in void
- out void
Sprite:unMap
- in void
- out void
Sprite:unmarkAsGoal
- in void
- out void
Alias: unsetAsGoal
Sprite:unsetAsGoal
- in void
- out void
Alias: unmarkAsGoal
Sprite:width
- in void
- out int width