-
Notifications
You must be signed in to change notification settings - Fork 7
Lua Script API: Object Functions
Initializes the creation of a colored fill texture; Must be declared after the makeLuaSprite()
function.
-
tag
- The sprite object's tag name to be used. -
width
- The width value in pixels of the object; Default value:256
. -
height
- The height value in pixels of the object; Default value:256
. -
color
- The color value of the object; Default value:FFFFFF
.
Changes the sprite texture with a new one. With an option to set the crop size of the sprite object.
-
variable
- The sprite object's tag name to be used. -
image
- The new image sprite for the sprite object to be used. -
gridX
- An optional parameter, The crop width of the sprite texture; Default value:0
. -
gridY
- An optional parameter, The crop height of the sprite texture; Default value:0
.
Changes the blend mode of the object. If you want to see more blend modes, click here. (Works similar to how Photoshop does it)
-
obj
- The sprite object's tag name to be used. -
blend
- The blend mode to be used; Example:add
,darken
,invert
, etc; Default value:''
.
Plays an existing animation of the sprite object; it can override an animation. If there are two or similar names inside the name
parameter; this rule is applied to all name
parameters.
-
obj
- The sprite object's tag name to be used. -
name
- The specified name of the animation to use. -
forced
- Whether the animation will restart if the animation name is the same one as the animation currently playing; Default value:false
. -
reverse
- An optional parameter, Whether the animation will be played backwards; Default valuefalse
. -
startFrame
- An optional parameter, The frame in the animation to start from; Default value:0
.
Adds a new animation of the sprite object.
-
obj
- The sprite object's tag name to be used. -
name
- The specified name of the animation to use. -
frames
- The indices indicating what animation frames to play in what order; Example:{1, 2, 3}
. -
framerate
- The speed in frames per second that the animation should play at; Default value:24
. -
loop
- Whether the animation will loop or not; Default valuetrue
.
Adds a new animation from the xml
file for the sprite object to use.
-
obj
- The sprite object's tag name to be used. -
name
- The specified name of the animation to use. -
prefix
- The prefix name inside thexml
file to be played. -
framerate
- The speed in frames per second that the animation should play at; Default value:24
. -
loop
- Whether the animation will loop or not; Default value:true
.
addAnimationByIndices(obj:String, name:String, prefix:String, indices:String, framerate:Int = 24, loop:Bool = false)
Note: In versions below 0.7, you must use
addAnimationByIndicesLoop
if you want to loop your animation, as the sixth parameter here does not exist; All the parameters will be the same excluding the loop parameter.
Adds a new animation with the specified indices for the animation frames to play for the sprite object to use.
-
obj
- The sprite object's tag name to be used. -
name
- The specified name of the animation to use. -
prefix
- The prefix name inside thexml
file to be played. -
frames
- The indices indicating what animation frames to play in what order; Example:1, 2, 3
. -
framerate
- The speed in frames per second that the animation should play at; Default value:24
. -
loop
- Whether the animation will loop or not; Default value:false
.
Adds a new offset value on each animation.
-
obj
- The sprite object's tag name to be used. -
anim
- The specified name of the animation to use. -
x
- The new x offset value of the animation. -
y
- the new y offset value of the animation.
Loads the Lua sprites animation frames.
-
variable
The sprite object's tag name to be used. -
image
- The image sprite for the sprite to use. -
spriteType
- An optional parameter, The specified sprite type of the Lua sprite could be either a sprite-sheet forsparrow
or texture-atlas fortex
; Default value:sparrow
.
Important
It's highly recommended that you use this on the onCreate()
callback. These functions are mainly used for avoiding a massive game freeze when an asset first gets used.
Pre-caches the sprite character, this used if you're switching characters.
-
name
- Thejson
name of the character. -
type
- The character type to be used; Can be either:boyfriend
,dad
orgf
.
Pre-caches the image sprite; Must be relative to mods/images
, assets/images
, or assets/shared/images
folders.
-
name
- The image sprite for the sprite to use. -
allowGPU
- An optional parameter, Whether to allow to cache on the GPU if GPU Caching is enabled; Default value:true
.
Pre-caches the sound; Must be relative to mods/sounds
or assets/sounds
folders.
-
name
- Theogg
sound file to be played.
Pre-caches the music; Must be relative to mods/music
or assets/music
folders.
-
name
- Theogg
music file to be played.
Sets the current layer position of the object with a new value.
-
obj
- The object's tag name to be used. -
position
- The new layer position to be set.
Gets the current layer position of the object current value; Returns an int
number.
-
obj
- The object's tag name to be used.
Checks if two objects are overlapping each-other; Returns a boolean
.
-
obj1
- The first object tag name to be used. -
obj2
- The second object tag name to be used.
Sets the object graphic size by pixels; Not to be confused with scaleObject()
.
-
obj
- The object's tag name to be used. -
x
- The width value of the object to be set. -
y
- The height value of the object to be set; Default value:0
. -
updateHitbox
- Whether it will update the object's dimension or hitbox; Default value:true
.
Sets the object size by scale properties.
-
obj
- The object's tag name to be used. -
x
- Thescale.x
value of the object to be set. -
y
- Thescale.y
value of the object to be set. -
updateHitbox
- Whether it will update the object's dimension or hitbox; Default value:true
.
Updates the object's dimension or hitboxes. Used this if you're changing scale of the object.
-
obj
- The object's tag name to be used.
Gets the midpoint x value in graphics, of the object; Not to be confused with getMidpointX()
function; Returns a float
number.
-
variable
- The object's tag name to be used.
Gets the midpoint y value in graphics, of the object; Not to be confused with getMidpointY()
function; Returns a float
number.
-
variable
- The object's tag name to be used.
Gets the midpoint x value of the object; Returns a float
number.
-
variable
- The object's tag name to be used.
Gets the midpoint y value of the object; Returns a float
number.
-
variable
- The object's tag name to be used.
Gets the screen x position of the object on the specific camera; Returns a float
number.
-
variable
- The object's tag name to be used. -
camera
- An optional parameter, The camera to check the position on.
Gets the screen y position of the object on the specific camera; Returns a float
number.
-
variable
- The object's tag name to be used. -
camera
- An optional parameter, The camera to check the position on.
Centers the object to either the X
or Y
position; Can also be both.
-
obj
- The object's tag name to be used. -
pos
- The position you want to set in; Can be either:X
,Y
,XY
; Default value:XY
.
Changes how much the object scrolls when the camera moves.
-
obj
- The object's tag name to be used. -
scrollX
- The x value of the scroll to be set. -
scrollY
- The y value of the scroll to be set.
Changes the object's camera state.
-
obj
- The object's tag name to be used. -
camera
- The camera state to be set in; Can be either:camGame
,camHUD
orcamOther
; Default value:''
.
Is the page in some way inaccurate? an error, a typo, or outdated data? To report it, use the "Issue Tab". Or do you wish to include a new function or add new information? use the "Pull Request Tab". Help is always appreciated!
- Event Callbacks
- Custom Sprite
- Custom Text
- Object Functions
- General Functions
- Scripting & File Functions
- Game Input Control Functions
- Language Translation
- HScript Functions
- Custom Substates
- Custom Shaders
- Deprecated & Removed Functions
- Sound & Music Functions
- Tweens & Timers Functions
- Reflection Functions
- Variables