Constructor
Methods
Object._clearCache()
(Called internally) Clears all cached transforms, and force-stops caching.
Object:addChild(child: Object)
Adds the specified object as a child to this object, and adds it to a stage if it was not added to one previously.
Calls child:onAdd(self)
.
@param child
— The object to be added.
@return child
— The object that was added.
Arguments:
child: Object | The object to be added. |
Returns:
child: Object | The object that was added. |
Object:addFX(fx: FXBase, id: string?)
Adds a DrawFX to the object.
DrawFX are classes that can apply visual effects to an object when drawing it.
Each effect will be applied in sequence, with effects of higher priority rendering later.
@param fx
— The DrawFX instance to add to the object.
@param id
— An optional string ID that can be used to reference the DrawFX in other functions.
@return fx
— The DrawFX instance that was added to the object.
Arguments:
fx: FXBase | The DrawFX instance to add to the object. |
id: string? | An optional string ID that can be used to reference the DrawFX in other functions. |
Returns:
fx: FXBase | The DrawFX instance that was added to the object. |
Object:applyScissor()
Called during drawing to apply cutouts.
Object:applyTransformTo(transform: any, floor_x: any, floor_y: any)
Arguments:
transform: any | |
floor_x: any | |
floor_y: any |
Object:canDebugSelect()
(Override)
By default, returns self.debug_select
.
@return can_select
— Whether the object can be selected by the Object Selection debug feature.
Returns:
can_select: boolean | Whether the object can be selected by the Object Selection debug feature. |
Object:clicked(button: any)
Returns whether the object has been clicked this frame.
@param number
— The mouse button to check. If not provided, it will check all buttons available.
@return success
— Whether the object was clicked.
@return button
— The mouse button that clicked the object. Useful if the 'button' argument was not provided.
Arguments:
button: any |
Returns:
success: boolean | Whether the object was clicked. |
button: number | The mouse button that clicked the object. Useful if the 'button' argument was not provided. |
Object:collidesWith(other: Collider|Object)
Whether the object is colliding with another object or collider.
@param other
— The object or collider to check collision with.
@return collided
— Whether the collision occurred or not.
Arguments:
other: Collider|Object | The object or collider to check collision with. |
Returns:
collided: boolean | Whether the collision occurred or not. |
Object:draw()
(Override) Called every frame by its parent during drawing if the object is visible.
By default, draws its children.
Object.endCache()
End caching the transforms of all objects (started with Object.startCache()).
Object:explode(x: number?, y: number?, dont_remove: boolean?, options: (table|"play_sound")?)
@param x
— The explosion's horizontal offset.
@param y
— The explosion's vertical offset.
@param dont_remove
— Whether the object should not be removed.
@param options
— Additional properties.
options:
| "play_sound" -- Whether it should play the sound. (Defaults to true)
Arguments:
x: number? | The explosion's horizontal offset. |
y: number? | The explosion's vertical offset. |
dont_remove: boolean? | Whether the object should not be removed. |
options: (table|"play_sound")? | Additional properties. |
Returns:
1: Explosion|nil |
Object:fadeOutAndRemove(time: number?)
Fades the object's alpha
to 0 over time
seconds, then removes it.
@param time
— The amount of time, in seconds, that the fade should take. (Defaults to 1 second)
Arguments:
time: number? | The amount of time, in seconds, that the fade should take. (Defaults to 1 second) |
Object:fadeOutSpeedAndRemove(speed: number?)
Fades the object's alpha
to 0 at a speed of speed
per frame, then removes it.
@param speed
— The amount that the object's alpha
should approach the target value, per frame at 30FPS. (Defaults to 0.04)
Arguments:
speed: number? | The amount that the object's |
Object:fadeTo(target: number, time: number?, callback: function?)
Fades the object's alpha
to the specified value over time
seconds.
@param target
— The alpha value that the object's alpha
should approach.
@param time
— The amount of time, in seconds, that the fade should take. (Defaults to 1 second)
@param callback
— A function that will be called when the alpha value is reached. Receives self
as an argument.
Arguments:
target: number | The alpha value that the object's |
time: number? | The amount of time, in seconds, that the fade should take. (Defaults to 1 second) |
callback: function? | A function that will be called when the alpha value is reached. Receives |
Object:fadeToSpeed(target: number, speed: number?, callback: function?)
Fades the object's alpha
to the specified value at a speed of speed
per frame.
@param target
— The alpha value that the object's alpha
should approach.
@param speed
— The amount that the object's alpha
should approach the target value, per frame at 30FPS. (Defaults to 0.04)
@param callback
— A function that will be called when the alpha value is reached. Receives self
as an argument.
Arguments:
target: number | The alpha value that the object's |
speed: number? | The amount that the object's |
callback: function? | A function that will be called when the alpha value is reached. Receives |
Object:getCameraOrigin()
Returns the camera origin of the object, simplifying to be a ratio relative to its width and height if its current camera origin is exact.
@return x
— The horizontal camera origin of the object.
@return y
— The vertical camera origin of the object.
Returns:
x: number | The horizontal camera origin of the object. |
y: number | The vertical camera origin of the object. |
Object:getCameraOriginExact()
Returns the camera origin of the object, multiplying to give the exact pixels if its current camera origin is not exact.
@return x
— The horizontal camera origin of the object.
@return y
— The vertical camera origin of the object.
Returns:
x: number | The horizontal camera origin of the object. |
y: number | The vertical camera origin of the object. |
Object:getColor()
Returns the values of the object's color
and alpha
values.
@return r
— The red value of the object's color
.
@return g
— The green value of the object's color
.
@return b
— The blue value of the object's color
.
@return a
— The alpha
value of the object.
Returns:
r: number | The red value of the object's |
g: number | The green value of the object's |
b: number | The blue value of the object's |
a: number | The |
Object:getCutout()
Returns the object's cutout
values.
@return The
— cutout_left
value of the object.
@return The
— cutout_top
value of the object.
@return The
— cutout_right
value of the object.
@return The
— cutout_bottom
value of the object.
Returns:
The: number|nil |
|
The: number|nil |
|
The: number|nil |
|
The: number|nil |
|
Object:getDebugInfo()
(Override)
By default, returns an empty table.
@return info
— A list of strings to display if the object is selected by the Object Selection debug feature.
Returns:
info: table | A list of strings to display if the object is selected by the Object Selection debug feature. |
Object:getDebugOptions(context: ContextMenu)
(Override) Defines options that can be used when selecting the object with the Object Selection debug feature.
By default, defines options that all objects use.
@param context
— The menu object containing the debug options that can be used.
To define an option, use context:addMenuItem(name: string, description: string, code: function)
, where:
name
defines the name that appears in the menu.description
defines the text that appears when hovering over the option.code
is the function that will be called when selecting the option.
@return context
— The modified menu object.
Arguments:
context: ContextMenu | The menu object containing the debug options that can be used. |
Returns:
context: ContextMenu | The modified menu object. |
Object:getDebugRectangle()
(Override) Returns a table defining the rectangle to use for selecting the object with the Object Selection debug feature.
By default, returns self.debug_rect
, or a rectangle with the same width and height as the object if self.debug_rect
is nil
.
@return rectangle
— A table containing 4 number values, defining the x
, y
, width
and height
of the selection rectangle.
Returns:
rectangle: table | A table containing 4 number values, defining the |
Object:getDirection()
Returns the object's physics.direction
, or the object's rotation
if physics.match_rotation
is true.
@return dir
— The movement direction of the object.
Returns:
dir: number | The movement direction of the object. |
Object:getDrawColor()
Returns the object's color and alpha.
If the object's inherit_color
is true, the result is multiplied by its parent's color and alpha, to get the color it should draw at.
@return r
— The red value of the object's draw color.
@return g
— The green value of the object's draw color.
@return b
— The blue value of the object's draw color.
@return a
— The object's draw alpha.
Returns:
r: number | The red value of the object's draw color. |
g: number | The green value of the object's draw color. |
b: number | The blue value of the object's draw color. |
a: number | The object's draw alpha. |
Object:getFX(id: string|Class|FXBase)
Returns a DrawFX added to the object.
@param id
— A string referring to the ID of a DrawFX, the class type that a DrawFX includes, or a DrawFX instance.
@return fx
— A DrawFX instance if the object has one that matches the ID, or nil
otherwise.
Arguments:
id: string|Class|FXBase | A string referring to the ID of a DrawFX, the class type that a DrawFX includes, or a DrawFX instance. |
Returns:
fx: FXBase|nil | A DrawFX instance if the object has one that matches the ID, or |
Object:getFullScale()
Returns the object's scale, multiplied by its parent's full scale.
@return x
— The horizontal scale of the object.
@return y
— The vertical scale of the object.
Returns:
x: number | The horizontal scale of the object. |
y: number | The vertical scale of the object. |
Object:getHierarchy()
@return hierarchy
— A table of all parents between this object and its stage (inclusive).
Returns:
hierarchy: table | A table of all parents between this object and its stage (inclusive). |
Object:getHitbox()
Returns the dimensions of the object's collider
if that collider is a Hitbox.
@return x
— The x
position of the collider, relative to the object.
@return y
— The y
position of the collider, relative to the object.
@return width
— The width
of the collider, in pixels.
@return height
— The height
of the collider, in pixels.
Returns:
x: number|nil | The |
y: number|nil | The |
width: number|nil | The |
height: number|nil | The |
Object:getLayer()
Returns the layer of the object.
@return The
— layer
value of the object.
Returns:
The: number |
|
Object:getOrigin()
Returns the origin of the object, simplifying to be a ratio relative to its width and height if its current origin is exact.
@return x
— The horizontal origin of the object.
@return y
— The vertical origin of the object.
Returns:
x: number | The horizontal origin of the object. |
y: number | The vertical origin of the object. |
Object:getOriginExact()
Returns the origin of the object, multiplying to give the exact pixels if its current origin is not exact.
@return x
— The horizontal origin of the object.
@return y
— The vertical origin of the object.
Returns:
x: number | The horizontal origin of the object. |
y: number | The vertical origin of the object. |
Object:getParallax()
Returns the parallax of the object.
@return x
— The parallax_x
value of the object.
@return y
— The parallax_y
value of the object.
Returns:
x: number | The |
y: number | The |
Object:getParallaxOrigin()
Returns the parallax origin of the object.
@return x
— The parallax_origin_x
value of the object.
@return y
— The parallax_origin_y
value of the object.
Returns:
x: number | The |
y: number | The |
Object:getPosition()
Returns the position of the object.
@return x
— The x
position of the object.
@return y
— The y
position of the object.
Returns:
x: number | The |
y: number | The |
Object:getRelativePos(x: number?, y: number?, other: Object?)
Returns the specified position for the object, relative to another object.
@param x
— The x
position relative to the object.
@param y
— The y
position relative to the object.
@param other
— The object the returned values should be relative to.
@return x
— The new x
position relative to the other
object.
@return y
— The new y
position relative to the other
object.
Arguments:
x: number? | The |
y: number? | The |
other: Object? | The object the returned values should be relative to. |
Returns:
x: number | The new |
y: number | The new |
Object:getRelativePosFor(other: Object)
Returns the object's position, relative to another object.
@param other
— The object the returned values should be relative to.
@return x
— The new x
position relative to the other
object.
@return y
— The new y
position relative to the other
object.
Arguments:
other: Object | The object the returned values should be relative to. |
Returns:
x: number | The new |
y: number | The new |
Object:getRotationOrigin()
Returns the rotation origin of the object, simplifying to be a ratio relative to its width and height if its current rotation origin is exact.
If the object doesn't have a rotation origin defined, it will return self:getOrigin()
instead.
@return x
— The horizontal rotation origin of the object.
@return y
— The vertical rotation origin of the object.
Returns:
x: number | The horizontal rotation origin of the object. |
y: number | The vertical rotation origin of the object. |
Object:getRotationOriginExact()
Returns the rotation origin of the object, multiplying to give the exact pixels if its current rotation origin is not exact.
If the object doesn't have a rotation origin defined, it will return self:getOriginExact()
instead.
@return x
— The horizontal rotation origin of the object.
@return y
— The vertical rotation origin of the object.
Returns:
x: number | The horizontal rotation origin of the object. |
y: number | The vertical rotation origin of the object. |
Object:getScale()
Returns the scale of the object.
@return x
— The scale_x
value of the object.
@return y
— The scale_y
value of the object.
Returns:
x: number | The |
y: number | The |
Object:getScaleOrigin()
Returns the scaling origin of the object, simplifying to be a ratio relative to its width and height if its current scaling origin is exact.
If the object doesn't have a scaling origin defined, it will return self:getOrigin()
instead.
@return x
— The horizontal scaling origin of the object.
@return y
— The vertical scaling origin of the object.
Returns:
x: number | The horizontal scaling origin of the object. |
y: number | The vertical scaling origin of the object. |
Object:getScaleOriginExact()
Returns the scaling origin of the object, multiplying to give the exact pixels if its current scaling origin is not exact.
If the object doesn't have a scaling origin defined, it will return self:getOriginExact()
instead.
@return x
— The horizontal scaling origin of the object.
@return y
— The vertical scaling origin of the object.
Returns:
x: number | The horizontal scaling origin of the object. |
y: number | The vertical scaling origin of the object. |
Object:getScaledHeight()
Returns the height of the object, accounting for scale.
@return height
— The height
of the object multiplied by its scale_y
.
Returns:
height: number | The |
Object:getScaledSize()
Returns the size of the object, accounting for scale.
@return width
— The width
of the object multiplied by its scale_x
.
@return height
— The height
of the object multiplied by its scale_y
.
Returns:
width: number | The |
height: number | The |
Object:getScaledWidth()
Returns the width of the object, accounting for scale.
@return width
— The width
of the object multiplied by its scale_x
.
Returns:
width: number | The |
Object:getScreenPos()
Returns the object's position relative to the topleft of the game window.
@return x
— The x
position of the object.
@return y
— The y
position of the object.
Returns:
x: number | The |
y: number | The |
Object:getSize()
Returns the size of the object.
@return width
— The width
value of the object.
@return height
— The height
value of the object.
Returns:
width: number | The |
height: number | The |
Object:getSortPosition()
(Override) Used by World to determine what position should be used when sorting its layer.
By default, returns self:getRelativePos(self.width/2, self.height)
.
@return x
— The horizontal position to use.
@return y
— The vertical position to use.
Returns:
x: number | The horizontal position to use. |
y: number | The vertical position to use. |
Object:getSpeedDir()
Returns the velocity and direction of the object's physics, converting physics.speed_x
and physics.speed_y
if necessary.
@return speed
— The linear speed the object moves at.
@return direction
— The direction the object is moving in.
Returns:
speed: number | The linear speed the object moves at. |
direction: number | The direction the object is moving in. |
Object:getSpeedXY()
Returns the horizontal and vertical speed of the object's physics, converting physics.speed
and physics.direction
if necessary
@return speed_x
— The horizontal speed of the object.
@return speed_y
— The vertical speed of the object.
Returns:
speed_x: number | The horizontal speed of the object. |
speed_y: number | The vertical speed of the object. |
Object:getStage()
@return stage
— The object's highest parent.
Returns:
stage: Object|nil | The object's highest parent. |
Object:isCameraAttachable()
(Override)
By default, returns true.
@return attached
— Whether a Camera attached to this object should follow it.
Returns:
attached: boolean | Whether a Camera attached to this object should follow it. |
Object:isFullyActive()
Returns whether the object and its parents are active, determining whether the object should be updated or not.
@return active
— Whether the object and its parents are active.
Returns:
active: boolean | Whether the object and its parents are active. |
Object:isFullyVisible()
Returns whether the object and its parents are visible, determining whether the object should be drawn or not.
@return visible
— Whether the object and its parents are visible.
Returns:
visible: boolean | Whether the object and its parents are visible. |
Object:isRemoved()
@return has_stage
— Whether the object has a parent or not.
Returns:
has_stage: boolean | Whether the object has a parent or not. |
Object:localToScreenPos(x: number?, y: number?)
Returns the specified position for the object, relative to the object's stage.
@param x
— The x
position relative to the object.
@param y
— The y
position relative to the object.
@return x
— The new x
position relative to the object's stage.
@return y
— The new y
position relative to the object's stage.
Arguments:
x: number? | The |
y: number? | The |
Returns:
x: number | The new |
y: number | The new |
Object:move(x: number, y: number, speed: number?)
Moves the object's x
and y
values by the specified values.
@param x
— How much to add to the object's x
value.
@param y
— How much to add to the object's y
value.
@param speed
— How much to multiply the x
and y
movement by. (Defaults to 1)
Arguments:
x: number | How much to add to the object's |
y: number | How much to add to the object's |
speed: number? | How much to multiply the |
Object:onAdd(parent: Object)
(Override) Called when the object is added to a parent object via parent:addChild(self)
or self:setParent(parent)
.
@param parent
— The parent that the object is being added to.
Arguments:
parent: Object | The parent that the object is being added to. |
Object:onAddToStage(stage: Object)
(Override) Called when the object is first added to the Game stage, via parent:addChild(self)
or self:setParent(parent)
.
Will not be called when changing to a new parent via self:setParent(new_parent)
if the object had a parent prior.
@param stage
— The Stage object that the object is being added to.
Arguments:
stage: Object | The Stage object that the object is being added to. |
Object:onRemove(parent: Object)
(Override) Called when the object is removed from its parent object via self:remove()
, parent:removeChild(self)
, or self:setParent(new_parent)
.
@param parent
— The parent that the object is being removed from.
Arguments:
parent: Object | The parent that the object is being removed from. |
Object:onRemoveFromStage(stage: Object)
(Override) Called when the object is removed from the Game stage via self:remove()
or parent:removeChild(self)
.
Will not be called when changing to a new parent via self:setParent(new_parent)
.
@param stage
— The Stage object that the object was a child of.
Arguments:
stage: Object | The Stage object that the object was a child of. |
Object:processDrawFX(canvas: any, transformed: any)
Arguments:
canvas: any | |
transformed: any |
Returns:
1: unknown |
Object:remove()
Removes the object from its parent.
Object:removeChild(child: Object)
Removes the specified object from this object's children, and removes it from its stage.
Calls child:onRemove(self)
.
@param child
— The object to be removed.
@return child
— The object that was removed.
Arguments:
child: Object | The object to be removed. |
Returns:
child: Object | The object that was removed. |
Object:removeFX(id: string|Class|FXBase)
Removes the specified DrawFX from the object.
@param id
— A string referring to the ID of a DrawFX, the class type that a DrawFX includes, or a DrawFX instance.
@return fx
— The removed DrawFX instance if the object has one that matches the ID, or nil
otherwise.
Arguments:
id: string|Class|FXBase | A string referring to the ID of a DrawFX, the class type that a DrawFX includes, or a DrawFX instance. |
Returns:
fx: FXBase|nil | The removed DrawFX instance if the object has one that matches the ID, or |
Object:resetGraphics()
Resets all of the object's graphics
table values to their default values,
making it so it will stop transforming if it was before.
Object:resetPhysics()
Resets all of the object's physics
table values to their default values,
making it so it will stop moving if it was before.
Object:screenToLocalPos(x: number?, y: number?)
Returns the specified position for the object's stage, relative to this object.
@param x
— The x
position relative to the object's stage.
@param y
— The y
position relative to the object's stage.
@return x
— The new x
position relative to the object.
@return y
— The new y
position relative to the object.
Arguments:
x: number? | The |
y: number? | The |
Returns:
x: number | The new |
y: number | The new |
Object:setCameraOrigin(x: number, y: number?)
Sets the object's camera_origin_x
and camera_origin_y
values to the specified origin, and sets camera_origin_exact
to false.
The camera origin set by this function will therefore be a ratio relative to the object's width and height.
@param x
— The value to set camera_origin_x
to.
@param y
— The value to set camera_origin_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setCameraOriginExact(x: number, y: number?)
Sets the object's camera_origin_x
and camera_origin_y
values to the specified origin, and sets camera_origin_exact
to true.
The camera origin set by this function will therefore be in exact pixels.
@param x
— The value to set camera_origin_x
to.
@param y
— The value to set camera_origin_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setColor(r: number, g: number, b: number, a: number?)
Sets the object's color
and alpha
values to the specified color.
@param r
— The red value to set for the object's color
.
@param g
— The green value to set for the object's color
.
@param b
— The blue value to set for the object's color
.
@param a
— The value to set alpha
to. (Doesn't change alpha if unspecified)
@param color
— The value to set color
to. Can optionally define a 4th value to set alpha.
Arguments:
r: number | The red value to set for the object's |
g: number | The green value to set for the object's |
b: number | The blue value to set for the object's |
a: number? | The value to set |
Object:setCutout(left: number|nil, top: number|nil, right: number|nil, bottom: number|nil)
Sets the object's cutout
values to the specified cutout.
@param left
— The value to set cutout_left
to.
@param top
— The value to set cutout_top
to.
@param right
— The value to set cutout_right
to.
@param bottom
— The value to set cutout_bottom
to.
Arguments:
left: number|nil | The value to set |
top: number|nil | The value to set |
right: number|nil | The value to set |
bottom: number|nil | The value to set |
Object:setDirection(dir: number)
Sets the object's movement direction to the specified direction, or its rotation if physics.match_rotation
is true.
@param dir
— The value to set physics.direction
or rotation
to.
Arguments:
dir: number | The value to set |
Object:setGraphics(graphics: graphics_table)
Resets the object's graphics
and sets new values for it.
@param graphics
— A table of values to set for the object's graphics transformation.
Arguments:
graphics: graphics_table | A table of values to set for the object's graphics transformation. |
Object:setHitbox(x: number, y: number, w: number, h: number)
Sets the object's collider
to a new Hitbox with the specified dimensions.
@param x
— The x
position of the collider, relative to the object.
@param y
— The y
position of the collider, relative to the object.
@param w
— The width
of the collider, in pixels.
@param h
— The height
of the collider, in pixels.
Arguments:
x: number | The |
y: number | The |
w: number | The |
h: number | The |
Object:setLayer(layer: number)
Sets the object's layer
, and updates its position in its parent's children list.
@param layer
— The value to set layer
to.
Arguments:
layer: number | The value to set |
Object:setOrigin(x: number, y: number?)
Sets the object's origin_x
and origin_y
values to the specified origin, and sets origin_exact
to false.
The origin set by this function will therefore be a ratio relative to the object's width and height.
@param x
— The value to set origin_x
to.
@param y
— The value to set origin_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setOriginExact(x: number, y: number?)
Sets the object's origin_x
and origin_y
values to the specified origin, and sets origin_exact
to true.
The origin set by this function will therefore be in exact pixels.
@param x
— The value to set origin_x
to.
@param y
— The value to set origin_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setParallax(x: number, y: number?)
Sets the object's parallax_x
and parallax_y
to the specified parallax.
@param x
— The value to set parallax_x
to.
@param y
— The value to set parallax_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setParallaxOrigin(x: number, y: number)
Sets the object's parallax_origin_x
and parallax_origin_y
values to the specified origin.
@param x
— The value to set parallax_origin_x
to.
@param y
— The value to set parallax_origin_y
to.
Arguments:
x: number | The value to set |
y: number | The value to set |
Object:setParent(parent: Object)
Sets the object's parent, removing it from its previous parent if it had one.
@param parent
— The object to add self
to.
Arguments:
parent: Object | The object to add |
Object:setPhysics(physics: physics_table)
Resets the object's physics
and sets new values for it.
@param physics
— A table of values to set for the object's physics.
Arguments:
physics: physics_table | A table of values to set for the object's physics. |
Object:setPosition(x: number, y: number)
Sets the object's x
and y
values to the specified position.
@param x
— The value to set x
to.
@param y
— The value to set y
to.
Arguments:
x: number | The value to set |
y: number | The value to set |
Object:setRotationOrigin(x: number, y: number?)
Sets the object's rotation_origin_x
and rotation_origin_y
values to the specified origin, and sets rotation_origin_exact
to false.
The rotation origin set by this function will therefore be a ratio relative to the object's width and height.
@param x
— The value to set rotation_origin_x
to.
@param y
— The value to set rotation_origin_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setRotationOriginExact(x: number, y: number?)
Sets the object's rotation_origin_x
and rotation_origin_y
values to the specified origin, and sets rotation_origin_exact
to true.
The rotation origin set by this function will therefore be in exact pixels.
@param x
— The value to set rotation_origin_x
to.
@param y
— The value to set rotation_origin_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setScale(x: number, y: number?)
Sets the object's scale_x
and scale_y
values to the specified scale.
@param x
— The value to set scale_x
to.
@param y
— The value to set scale_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setScaleOrigin(x: number, y: number?)
Sets the object's scale_origin_x
and scale_origin_y
values to the specified origin, and sets scale_origin_exact
to false.
The scaling origin set by this function will therefore be a ratio relative to the object's width and height.
@param x
— The value to set scale_origin_x
to.
@param y
— The value to set scale_origin_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setScaleOriginExact(x: number, y: number?)
Sets the object's scale_origin_x
and scale_origin_y
values to the specified origin, and sets scale_origin_exact
to true.
The scaling origin set by this function will therefore be in exact pixels.
@param x
— The value to set scale_origin_x
to.
@param y
— The value to set scale_origin_y
to. (Defaults to the x
parameter)
Arguments:
x: number | The value to set |
y: number? | The value to set |
Object:setScreenPos(x: number, y: number)
Sets the object's position relative to the topleft of the game window.
@param x
— The x
position for the object.
@param y
— The y
position for the object.
Arguments:
x: number | The |
y: number | The |
Object:setSize(width: number, height: number?)
Sets the object's width
and height
values to the specified size.
@param width
— The value to set width
to.
@param height
— The value to set height
to. (Defaults to the width
parameter)
Arguments:
width: number | The value to set |
height: number? | The value to set |
Object:setSpeed(x: number, y: number)
Sets the object's speed in its physics
table.
@param x
— The value to set physics.speed_x
to.
@param y
— The value to set physics.speed_y
to.
@param speed
— The value to set physics.speed
to.
Arguments:
x: number | The value to set |
y: number | The value to set |
Object:shake(x: number?, y: number?, friction: number?, delay: number?)
Makes the object shake by the specified amount.
@param x
— The amount of shake in the x
direction. (Defaults to 4
)
@param y
— The amount of shake in the y
direction. (Defaults to 0
)
@param friction
— The amount that the shake should decrease by, per frame at 30FPS. (Defaults to 1
)
@param delay
— The time it takes for the object to invert its shake direction, in seconds. (Defaults to 1/30
)
Arguments:
x: number? | The amount of shake in the |
y: number? | The amount of shake in the |
friction: number? | The amount that the shake should decrease by, per frame at 30FPS. (Defaults to |
delay: number? | The time it takes for the object to invert its shake direction, in seconds. (Defaults to |
Object:shiftOrigin(ox: number, oy: number?)
Sets the object's relative origin to the specified values, and adjusts its position so that it stays in the same place visually.
@param ox
— The value to set origin_x
to.
@param oy
— The value to set origin_y
to. (Defaults to the ox
parameter)
Arguments:
ox: number | The value to set |
oy: number? | The value to set |
Object:shiftOriginExact(ox: number, oy: number?)
Sets the object's exact origin to the specified values, and adjusts its position so that it stays in the same place visually.
@param ox
— The value to set origin_x
to.
@param oy
— The value to set origin_y
to. (Defaults to the ox
parameter)
Arguments:
ox: number | The value to set |
oy: number? | The value to set |
Object:slidePath(path: table, options: (table|"after"|"ease"|"loop"|"move_func"...(+6))?)
Moves the object along a path of points.
@param path
— A table containing a list of tables with two number values in each, defining a list of points the object should follow.
@param options
— A table defining additional properties that the path should use.
options:
| "time" -- The amount of time, in seconds, that the object should take to travel along the full path.
| "speed" -- The speed at which the object should travel along the path, in pixels per frame at 30FPS.
| "ease" -- The ease type to use when travelling along the path. Unused if `speed` is specified instead of `time`. (Defaults to "linear")
| "after" -- A function that will be called when the end of the path is reached. Receives no arguments.
| "move_func" -- A function called every frame while the object is travelling along the path. Receives `self` and the `x` and `y` offset from the previous frame as arguments.
| "relative" -- Whether the path should be relative to the object's current position, or simply set its position directly.
| "loop" -- Whether the path should loop back to the first point when reaching the end, or if it should stop.
| "reverse" -- If true, reverse all of the points on the path.
| "skip" -- A number defining how many points of the path to skip.
| "snap" -- Whether the object's position should immediately "snap" to the first point, or if its initial position should be counted as a point on the path.
Arguments:
path: table | A table containing a list of tables with two number values in each, defining a list of points the object should follow. |
options: (table|"after"|"ease"|"loop"|"move_func"...(+6))? | A table defining additional properties that the path should use. |
Object:slideTo(x: number, y: number, time: number?, ease: string?, after: function?)
Moves the object's x
and y
values to the new specified position over time
seconds.
@param x
— The new x
value to approach.
@param y
— The new y
value to approach.
@param marker
— A map marker whose position the object should approach.
@param time
— The amount of time, in seconds, that the slide should take. (Defaults to 1 second)
@param ease
— The ease type to use when moving to the new position. (Defaults to "linear")
@param after
— A function that will be called when the target position is reached. Receives no arguments.
@return success
— Whether the sliding will occur. False if the object's current position is already at the specified position, and true otherwise.
Arguments:
x: number | The new |
y: number | The new |
time: number? | The amount of time, in seconds, that the slide should take. (Defaults to 1 second) |
ease: string? | The ease type to use when moving to the new position. (Defaults to "linear") |
after: function? | A function that will be called when the target position is reached. Receives no arguments. |
Returns:
success: boolean | Whether the sliding will occur. False if the object's current position is already at the specified position, and true otherwise. |
Object:slideToSpeed(x: number, y: number, speed: number?, after: function?)
Moves the object's x
and y
values to the new specified position at a speed of speed
pixels per frame.
@param x
— The new x
value to approach.
@param y
— The new y
value to approach.
@param marker
— A map marker whose position the object should approach.
@param speed
— The amount that the object's x
and y
should approach the specified position, in pixels per frame at 30FPS. (Defaults to 4)
@param after
— A function that will be called when the target position is reached. Receives no arguments.
@return success
— Whether the sliding will occur. False if the object's current position is already at the specified position, and true otherwise.
Arguments:
x: number | The new |
y: number | The new |
speed: number? | The amount that the object's |
after: function? | A function that will be called when the target position is reached. Receives no arguments. |
Returns:
success: boolean | Whether the sliding will occur. False if the object's current position is already at the specified position, and true otherwise. |
Object.startCache()
Begin caching the transforms of all objects.
This should be called before any collision checks, and ended with Object.endCache().
If an object is moved mid-cache, call Object.uncache() on it.
Object:stopShake()
Stops the object from shaking.
Object.uncache(obj: any)
Uncache an object's transform, if Object.startCache() is active.
This recalculates the object's transform and all of its children, incase it was moved.
Arguments:
obj: any |
Object.uncacheFull(obj: any)
(Called internally) Uncaches an object's full transform, including all of its children.
Arguments:
obj: any |
Object:update()
(Override) Called every frame by its parent if the object is active.
By default, updates its physics and graphics tables, and its children.
Fields
Object._dont_draw_children: boolean
(Used internally) Whether the object should draw its children or not.
Object.active: boolean
Whether the object should update itself and its children.
Object.alpha: number
The alpha transparency of the object, between 0 (invisible) and 1 (fully visible).
Object.camera: Camera|nil
A camera instance that will automatically move and scale the object and its children. Should be nil
for most objects.
Object.camera_origin_exact: boolean
Whether the object's camera origin is measured as a ratio of its width
and height
, or in exact pixels. (Defaults to false)
Object.camera_origin_x: number
The horizontal camera origin of the object. (Defaults to 0.5)
Camera origin defines what position on the object a camera attached to it should follow.
Object.camera_origin_y: number
The vertical camera origin of the object. (Defaults to 0.5)
Camera origin defines what position on the object a camera attached to it should follow.
Object.children: table
A list of all of this object's children.
Object.children_to_remove: table
(Used internally) A list of children for the object to remove next time it updates.
Object.collidable: boolean
Whether the object should be able to collide with other objects.
Object.collider: Collider|nil
A Collider class used to check collision with other objects.
Object.color: table
The color of the object in the form {R, G, B}.
The values of R, G, and B are between 0 and 1.
Object.cutout_bottom: number|nil
The amount of pixels to cut from the bottom of the object when drawing.
Object.cutout_left: number|nil
The amount of pixels to cut from the left of the object when drawing.
Object.cutout_right: number|nil
The amount of pixels to cut from the right of the object when drawing.
Object.cutout_top: number|nil
The amount of pixels to cut from the top of the object when drawing.
Object.debug_rect: table|nil
Defines the rectangle used for selecting the object with the Object Selection debug feature.
Object.debug_select: boolean
Whether the object can be selected by the Object Selection debug feature. (Defaults to true)
Object.draw_children_above: number|nil
If defined, children with a layer greater than this value will be drawn above the object.
Object.draw_children_below: number|nil
If defined, children with a layer less than this value will be drawn underneath the object.
Object.draw_fx: table
A list of all DrawFX that are being applied to the object.
Object.flip_x: boolean
Whether the object is flipped horizontally.
Object.flip_y: boolean
Whether the object is flipped vertically.
Object.graphics: graphics_table
A table of data, defining ways the object's properties should automatically update.
Object.height: number
The height of the object.
Object.inherit_color: boolean
Whether the object's color will be multiplied by its parent's color.
Object.init_x: number
The horizontal position of the object when it was created.
Object.init_y: number
The vertical position of the object when it was created.
Object.last_x: number
The horizontal position of the object in the previous frame.
Object.last_y: number
The vertical position of the object in the previous frame.
Object.layer: number
The layer of the object within its parent.
Objects update and draw their children in order sorted by layer. Objects with a higher layer will update and draw later than objects with lower layers.
All children of an object will draw at the same visual layer as the parent. In other words, a child cannot render above an object that is higher than its parent, even if its own layer is higher.
Object.origin_exact: boolean
Whether the object's origin is measured as a ratio of its width
and height
, or in exact pixels. (Defaults to false)
Object.origin_x: number
The horizontal origin of the object.
Origin is used to define the point that the object is scaled, rotated, and positioned from.
This determines where the position (0, 0) is within the object.
If origin_exact
is false, the origin will be a ratio relative to the object's width
and height
, meaning an origin of 0.5, 0.5 will cause the object to be centered.
If it is true, then the origin will be measured in exact pixels.
Object.origin_y: number
The vertical origin of the object.
Origin is used to define the point that the object is scaled, rotated, and positioned from.
This determines where the position (0, 0) is within the object.
If origin_exact
is false, the origin will be a ratio relative to the object's width
and height
, meaning an origin of 0.5, 0.5 will cause the object to be centered.
If it is true, then the origin will be measured in exact pixels.
Object.parallax_origin_x: number
The horizontal position on the object's parent that the object's parallax will orient around.
Object.parallax_origin_y: number
The vertical position on the object's parent that the object's parallax will orient around.
Object.parallax_x: number|nil
How much an object's position will be affected by the camera horizontally.
A value of 1 means it fully moves with the camera (aka default behavior), and a value of 0 means it will not move at all when the camera moves.
Parallax will only affect an object if its parent has a camera.
Object.parallax_y: number|nil
How much an object's position will be affected by the camera vertically.
A value of 1 means it fully moves with the camera (aka default behavior), and a value of 0 means it will not move at all when the camera moves.
Parallax will only affect an object if its parent has a camera.
Object.parent: Object|nil
The object's parent.
Object.physics: physics_table
A table of data, defining ways the object should automatically move when updating.
Object.rotation: number
The rotation of the object, in radians. (0
is right, positive is clockwise)
Object.rotation_origin_exact: boolean
Whether the object's rotation origin is measured as a ratio of its width
and height
, or in exact pixels. (Defaults to false)
Object.rotation_origin_x: number|nil
The horizontal rotation origin of the object.
Rotation origin overrides the object's origin, and defines where the object will rotate from.
Object.rotation_origin_y: number|nil
The vertical rotation origin of the object.
Rotation origin overrides the object's origin, and defines where the object will rotate from.
Object.scale_origin_exact: boolean
Whether the object's scale origin is measured as a ratio of its width
and height
, or in exact pixels. (Defaults to false)
Object.scale_origin_x: number|nil
The horizontal scale origin of the object.
Scale origin overrides the object's origin, and defines where the object will scale from.
Object.scale_origin_y: number|nil
The vertical scale origin of the object.
Scale origin overrides the object's origin, and defines where the object will scale from.
Object.scale_x: number
The horizontal scale of the object.
Object.scale_y: number
The vertical scale of the object.
Object.timescale: number
A multiplier that determines the speed at which the object updates.
Object.update_child_list: boolean
(Used internally) If true, the object will re-sort its children list.
Object.visible: boolean
Whether the object should draw itself and its children.
Object.width: number
The width of the object.