Psych Engine - Spritesheet Functions
Psych Engine Logo
Psych Engine - Lua Script API

Spritesheet Functions

Functions to display images on screen.


makeLuaSprite

makeLuaSprite(tag:String, ?image:String = null, ?x:Float = 0, ?y:Float = 0):Void

Creates a Lua Sprite with a specific image and store it as the name input in "tag".

Examples:

Note: You will still have to add the Lua Sprite to the scene with addLuaSprite or it won't be visible.


makeAnimatedLuaSprite

makeAnimatedLuaSprite(tag:String, ?image:String = null, ?x:Float = 0, ?y:Float = 0, ?spriteType:String = 'auto'):Void

Creates an animated Lua Sprite with a specific image and .XML/.JSON/.TXT, then store it as the name input in "tag".

Examples:

Note: You will still have to add the Lua Sprite to the scene with addLuaSprite or it won't be visible.

Note 2: Follow these instructions to export properly from Aseprite.


makeGraphic

makeGraphic(tag:String, ?width:Int = 256, ?height:Int = 256, ?color:String = 'FFFFFF'):Void

Generates a solid color square as graphic for a Lua Sprite.

Examples:


loadGraphic

loadGraphic(tag:String, image:String = null, ?gridX:Int = 0, ?gridY:Int = 0):Void

Loads an image to a Lua Sprite, this image can be divided into frames in a consistently sized grid that doesn't require a .XML/.JSON/.TXT, which can be used as animation through "addAnimation".

Examples:


loadFrames

loadFrames(tag:String, image:String, ?spriteType:String = 'auto'):Void

Loads a specific image and .XML/.JSON/.TXT to a Lua Sprite.

Examples:

Note: Follow these instructions to export properly from Aseprite.


addAnimationByPrefix

addAnimationByPrefix(tag:String, name:String, prefix:String, ?framerate:Float = 24, ?loop:Bool = true):Bool

Adds an animation from a symbol.
Returns true if the operation was successful.

Examples:


addAnimationByIndices

addAnimationByIndices(tag:String, name:String, prefix:String, indices:Dynamic = null, ?framerate:Float = 24, ?loop:Bool = false):Bool

Adds an animation from a symbol, playing only the specified frames.
Returns true if the operation was successful.

Examples:


addAnimation

addAnimation(tag:String, name:String, frames:Dynamic = null, ?framerate:Float = 24, ?loop:Bool = true):Bool

Adds an animation from a grid done with "loadGraphic", playing only the specified frames.
Returns true if the operation was successful.

Examples:


addOffset

addOffset(tag:String, name:String, x:Float, y:Float):Bool

Adds an offset for the animation, offsets change automatically when you use "playAnim".
Returns true if the operation was successful.

Examples:


playAnim

playAnim(tag:String, name:String, ?forced:Bool = false, ?reverse:Bool = false, ?startFrame:Int = 0):Bool

Plays animation on a Sprite and updates offsets set with "addOffset".
Returns true if the operation was successful.

Examples:


addLuaSprite

addLuaSprite(tag:String, ?inFront:Bool = false):Void

Adds the Lua Sprite to the scene.

Examples:


removeLuaSprite

removeLuaSprite(tag:String, ?destroy:Bool = true, ?group:String = null):Void

Removes a Lua Sprite from the scene.

Examples:


luaSpriteExists

luaSpriteExists(tag:String):Bool

Returns if a Lua Sprite with a specific tag exists.