love.scene

Minimal scene graph designed for Love2D.
Developed and maintained by 2dengine.com
Last updated on January 04, 2024

scene

This is the main module of the scene graph library.
scene.copy(src, dest)This is an internal function
scene.destroy(t)This is an internal function
scene.new(t, ...)This is an internal function
scene.newCamera(x, y)Creates a new camera object. Alternatively, you can use layer:newCamera.
scene.newLayer(x, y)Creates a new layer object. Alternatively, you can use layer:newLayer.
scene.newSprite(x, y)Creates a new sprite object. Alternatively, you can use layer:newSprite.
scene.newView(x, y, width, height)Creates a new view object. If no parameters are supplied, the view takes on the dimensions of the window.

scene.copy(src, dest)

This is an internal function
nodesrc
Source node
nodedest
Destination node

scene.destroy(t)

This is an internal function
nodet
Existing node

scene.new(t, ...)

This is an internal function
nodet
Existing node
arguments...
Constructor arguments
Returns
node New node object

scene.newCamera(x, y)

Creates a new camera object. Alternatively, you can use layer:newCamera.
numberx
X coordinate
numbery
Y coordinatex
Returns
camera New camera object

scene.newLayer(x, y)

Creates a new layer object. Alternatively, you can use layer:newLayer.
numberx
X coordinate
numbery
Y coordinate
Returns
layer New layer object

scene.newSprite(x, y)

Creates a new sprite object. Alternatively, you can use layer:newSprite.
numberx
X coordinate
numbery
Y coordinate
Returns
sprite New sprite object

scene.newView(x, y, width, height)

Creates a new view object. If no parameters are supplied, the view takes on the dimensions of the window.
numberx (optional)
X-position in pixels
numbery (optional)
Y-position in pixels
numberwidth (optional)
Width in pixels
numberheight (optional)
Height in pixels
Returns
view New view object



node

Abstract scene graph node.
node.construct(x, y)This is an internal function
node:compareDepth(other)This is an internal function. Compares the depth of two nodes, based on their Y-coordinates.
node:deconstruct()This is an internal function
node:destroy()Destroys the node removing it from its parent layer.
node:getDepth()Gets the depth index relative to other nodes in the parent layer.
node:getParent()Gets the current parent layer of the node.
node:getPosition()Gets the position of the node.
node:getRoot()Returns the root layer of the node or nil if the current node does not have a parent.
node:getRotation()Gets the rotation of the node.
node:getScale()Gets the scale of the node.
node:getTransform()Gets the position and rotation of the node.
node:getVisible()Gets the visibility of the node. Non-visible nodes are not drawn at all.
node:localToParent(x, y)Converts a position from local to parent coordinates. The center of the parent layer is its origin.
node:localToRoot(x, y)Converts a position from local to scene coordinates. The origin of the scene is the center of the root layer.
node:localToWindow(x, y)Converts a position from local to window coordinates. This function works only if the root node is a view object or returns nil otherwise.
node:parentToLocal(x, y)Converts a position from parent to local coordinates. The center of the parent layer is its origin.
node:reset(x, y)This is an internal function
node:rootToLocal(x, y)Converts a position from scene to local coordinates. The origin of the scene is the center of the root layer.
node:setDepth(index)Sets the depth index relative to other nodes in the parent layer. Setting the depth to 1 will draw the node first, before all others. Setting the depth to 0 will draw the node last, after all others. This depth index may shift as nodes are added, removed or sorted.
node:setParent(parent)Sets the parent layer of the node. All nodes can have just one parent.
node:setPosition(x, y)Sets the position of the node.
node:setRotation(angle)Sets the rotation of the node.
node:setScale(sx, sy)Sets the scale of the node.
node:setTransform(x, y, angle)Sets the position and rotation of the node.
node:setVisible(True)Sets the visibility of the node. Non-visible nodes are not drawn at all.
node:type()Returns the node type as a string
node:windowToLocal(x, y)Converts a position from window to local coordinates. This function works only if the root node is a view object or returns nil otherwise.

node.construct(x, y)

This is an internal function
numberx
X-coordinate
numbery
Y-coordinate
Returns
node New node

node:compareDepth(other)

This is an internal function. Compares the depth of two nodes, based on their Y-coordinates.
nodeother
Other other
Returns
boolean True if this node is in front of the other

node:deconstruct()

This is an internal function

node:destroy()

Destroys the node removing it from its parent layer.

node:getDepth()

Gets the depth index relative to other nodes in the parent layer.
Returns
number Depth index

node:getParent()

Gets the current parent layer of the node.
Returns
layer Current parent layer

node:getPosition()

Gets the position of the node.
Returns
number X-coordinate
number Y-coordinate

node:getRoot()

Returns the root layer of the node or nil if the current node does not have a parent.
Returns
layer Root layer

node:getRotation()

Gets the rotation of the node.
Returns
number Angle in radians

node:getScale()

Gets the scale of the node.
Returns
number X-axis scale
number Y-axis scale

node:getTransform()

Gets the position and rotation of the node.
Returns
number X-coordinate
number Y-coordinate
number Angle in radians

node:getVisible()

Gets the visibility of the node. Non-visible nodes are not drawn at all.
Returns
boolean True if visible

node:localToParent(x, y)

Converts a position from local to parent coordinates. The center of the parent layer is its origin.
numberx
Local X-coordinate
numbery
Local Y-coordinate
Returns
number Parent X-coordinate
number Parent Y-coordinate

node:localToRoot(x, y)

Converts a position from local to scene coordinates. The origin of the scene is the center of the root layer.
numberx
Local X-coordinate
numbery
Local Y-coordinate
Returns
number Scene X-coordinate
number Scene Y-coordinate

node:localToWindow(x, y)

Converts a position from local to window coordinates. This function works only if the root node is a view object or returns nil otherwise.
numberx
Local X-coordinate
numbery
Local Y-coordinate
Returns
number Window X-coordinate
number Window Y-coordinate

node:parentToLocal(x, y)

Converts a position from parent to local coordinates. The center of the parent layer is its origin.
numberx
Parent X-coordinate
numbery
Parent Y-coordinate
Returns
number Local X-coordinate
number Local Y-coordinate

node:reset(x, y)

This is an internal function
numberx
X-coordinate
numbery
Y-coordinate

node:rootToLocal(x, y)

Converts a position from scene to local coordinates. The origin of the scene is the center of the root layer.
numberx
Scene X-coordinate
numbery
Scene Y-coordinate
Returns
number Local X-coordinate
number Local Y-coordinate

node:setDepth(index)

Sets the depth index relative to other nodes in the parent layer. Setting the depth to 1 will draw the node first, before all others. Setting the depth to 0 will draw the node last, after all others. This depth index may shift as nodes are added, removed or sorted.
numberindex
Depth index (could be negative)

node:setParent(parent)

Sets the parent layer of the node. All nodes can have just one parent.
layerparent
New parent layer

node:setPosition(x, y)

Sets the position of the node.
numberx
X-coordinate
numbery
Y-coordinate

node:setRotation(angle)

Sets the rotation of the node.
numberangle
Angle in radians

node:setScale(sx, sy)

Sets the scale of the node.
numbersx
X-axis scale
numbersy
Y-axis scale

node:setTransform(x, y, angle)

Sets the position and rotation of the node.
numberx
X-coordinate
numbery
Y-coordinate
numberangle
Angle in radians

node:setVisible(True)

Sets the visibility of the node. Non-visible nodes are not drawn at all.
booleanTrue
if visible

node:type()

Returns the node type as a string
Returns
string Node type ("Sprite", "Layer" or "View").

node:windowToLocal(x, y)

Converts a position from window to local coordinates. This function works only if the root node is a view object or returns nil otherwise.
numberx
Window X-coordinate
numbery
Window Y-coordinate
Returns
number Local X-coordinate
number Local Y-coordinate



sprite

Sprites are nodes in the scene which can be translated, scaled or rotated. Each sprite is assigned a "drawable" graphic, usually an image, quad or text. Sprites can also be assigned a specific color, alpha value and blending mode.
node
node:compareDepth(other)This is an internal function. Compares the depth of two nodes, based on their Y-coordinates.
node:destroy()Destroys the node removing it from its parent layer.
node:getDepth()Gets the depth index relative to other nodes in the parent layer.
node:getParent()Gets the current parent layer of the node.
node:getPosition()Gets the position of the node.
node:getRoot()Returns the root layer of the node or nil if the current node does not have a parent.
node:getRotation()Gets the rotation of the node.
node:getScale()Gets the scale of the node.
node:getTransform()Gets the position and rotation of the node.
node:getVisible()Gets the visibility of the node. Non-visible nodes are not drawn at all.
node:localToParent(x, y)Converts a position from local to parent coordinates. The center of the parent layer is its origin.
node:localToRoot(x, y)Converts a position from local to scene coordinates. The origin of the scene is the center of the root layer.
node:localToWindow(x, y)Converts a position from local to window coordinates. This function works only if the root node is a view object or returns nil otherwise.
node:parentToLocal(x, y)Converts a position from parent to local coordinates. The center of the parent layer is its origin.
node:rootToLocal(x, y)Converts a position from scene to local coordinates. The origin of the scene is the center of the root layer.
node:setDepth(index)Sets the depth index relative to other nodes in the parent layer. Setting the depth to 1 will draw the node first, before all others. Setting the depth to 0 will draw the node last, after all others. This depth index may shift as nodes are added, removed or sorted.
node:setParent(parent)Sets the parent layer of the node. All nodes can have just one parent.
node:setPosition(x, y)Sets the position of the node.
node:setRotation(angle)Sets the rotation of the node.
node:setScale(sx, sy)Sets the scale of the node.
node:setTransform(x, y, angle)Sets the position and rotation of the node.
node:setVisible(True)Sets the visibility of the node. Non-visible nodes are not drawn at all.
node:type()Returns the node type as a string
node:windowToLocal(x, y)Converts a position from window to local coordinates. This function works only if the root node is a view object or returns nil otherwise.
sprite
sprite.construct(x, y)This is an internal function Please use scene.newSprite or layer.newSprite instead.
sprite:deconstruct()This is an internal function
sprite:draw()This is an internal function
sprite:getAlpha()Gets the alpha value.
sprite:getColor()Gets the color.
sprite:getGraphic()Gets the "drawable" graphic and quad of the sprite.
sprite:getMode()Gets the blending mode.
sprite:getShader()Gets the shader used when drawing the sprite.
sprite:reset(x, y)Resets the node to its initial state.
sprite:setAlpha(alpha)Sets the alpha value.
sprite:setColor(red, green, blue)Sets the color.
sprite:setGraphic(drawable, quad, x, y, angle, sx, sy, ox, oy, kx, ky)Sets a "drawable" graphic or a quad for the sprite. This could be an image, text, mesh, canvas, etc. The "drawable" graphic can be transformed relative to the sprite's origin.
sprite:setMode(mode)Sets the blending mode.
sprite:setShader(shader)Sets the shader used when drawing the sprite.

sprite.construct(x, y)

This is an internal function Please use scene.newSprite or layer.newSprite instead.
numberx
X coordinate
numbery
Y coordinate
Returns
sprite New sprite

sprite:deconstruct()

This is an internal function

sprite:draw()

This is an internal function

sprite:getAlpha()

Gets the alpha value.
Returns
number Alpha value (0-1)

sprite:getColor()

Gets the color.
Returns
number Red value (0-1)
number Green value (0-1)
number Blue value (0-1)

sprite:getGraphic()

Gets the "drawable" graphic and quad of the sprite.
Returns
userdata Drawable graphic
userdata Quad or nil

sprite:getMode()

Gets the blending mode.
Returns
string mode Blend mode

sprite:getShader()

Gets the shader used when drawing the sprite.
Returns
userdata Shader object

sprite:reset(x, y)

Resets the node to its initial state.
numberx
X-coordinate
numbery
Y-coordinate

sprite:setAlpha(alpha)

Sets the alpha value.
numberalpha
Alpha value (0-1)

sprite:setColor(red, green, blue)

Sets the color.
numberred
Red value (0-1)
numbergreen
Green value (0-1)
numberblue
Blue value (0-1)

sprite:setGraphic(drawable, quad, x, y, angle, sx, sy, ox, oy, kx, ky)

Sets a "drawable" graphic or a quad for the sprite. This could be an image, text, mesh, canvas, etc. The "drawable" graphic can be transformed relative to the sprite's origin.
userdatadrawable
Drawable graphic
userdataquad (optional)
Optional quad
numberx (0)
X coordinate
numbery (0)
y coordinate
numberangle (0)
Angle
numbersx (1)
X axis scale
numbersy (1)
Y axis scale
numberox (0)
X axis offset
numberoy (0)
Y axis offset
numberkx (0)
X axis shearing
numberky (0)
Y axis shearing

sprite:setMode(mode)

Sets the blending mode.
stringmode
Blend mode: "alpha", "add", "subtract" or "multiply"

sprite:setShader(shader)

Sets the shader used when drawing the sprite.
userdatashader
Shader object



layer

Layers are basically groups of nodes, containing either sprites or other nested layers. Layers are helpful in ordering nodes along the Z-axis. Layers are used to build things like parallax, huds, minimaps and so on.
node
node:compareDepth(other)This is an internal function. Compares the depth of two nodes, based on their Y-coordinates.
node:destroy()Destroys the node removing it from its parent layer.
node:getDepth()Gets the depth index relative to other nodes in the parent layer.
node:getParent()Gets the current parent layer of the node.
node:getPosition()Gets the position of the node.
node:getRoot()Returns the root layer of the node or nil if the current node does not have a parent.
node:getRotation()Gets the rotation of the node.
node:getScale()Gets the scale of the node.
node:getTransform()Gets the position and rotation of the node.
node:getVisible()Gets the visibility of the node. Non-visible nodes are not drawn at all.
node:localToParent(x, y)Converts a position from local to parent coordinates. The center of the parent layer is its origin.
node:localToRoot(x, y)Converts a position from local to scene coordinates. The origin of the scene is the center of the root layer.
node:localToWindow(x, y)Converts a position from local to window coordinates. This function works only if the root node is a view object or returns nil otherwise.
node:parentToLocal(x, y)Converts a position from parent to local coordinates. The center of the parent layer is its origin.
node:rootToLocal(x, y)Converts a position from scene to local coordinates. The origin of the scene is the center of the root layer.
node:setDepth(index)Sets the depth index relative to other nodes in the parent layer. Setting the depth to 1 will draw the node first, before all others. Setting the depth to 0 will draw the node last, after all others. This depth index may shift as nodes are added, removed or sorted.
node:setParent(parent)Sets the parent layer of the node. All nodes can have just one parent.
node:setPosition(x, y)Sets the position of the node.
node:setRotation(angle)Sets the rotation of the node.
node:setScale(sx, sy)Sets the scale of the node.
node:setTransform(x, y, angle)Sets the position and rotation of the node.
node:setVisible(True)Sets the visibility of the node. Non-visible nodes are not drawn at all.
node:type()Returns the node type as a string
node:windowToLocal(x, y)Converts a position from window to local coordinates. This function works only if the root node is a view object or returns nil otherwise.
layer
layer.construct(x, y)This is an internal function Please use scene.newLayer or layer.newLayer instead.
layer:deconstruct()This is an internal function
layer:destroyChildren()Destroys all of the child nodes.
layer:draw()This is an internal function
layer:getChild(index)Returns a child node based on depth index (could be negative).
layer:getChildDepth(child)Gets the depth index of a child node.
layer:insertChild(child)This is an internal function Adds a new child node to the layer.
layer:newCamera(x, y)Creates a new camera at the given position. Sets the parent of the new camera to the current node.
layer:newLayer(x, y)Creates a new layer at the given position. Sets the parent of the new layer to the current node.
layer:newSprite(x, y)Creates a new sprite at the given position. Sets the parent of the new sprite to the current node.
layer:removeChild(child)This is an internal function Removes an existing child node from the layer.
layer:removeChildren()Removes all child nodes without destroying them.
layer:reset(x, y)This is an internal function
layer:setChildDepth(child, index)Sets the depth index of a child node. This depth index may shift as node are added, removed or sorted.
layer:sort(func)Sorts the child nodes based on a comparison function. If no comparison function is specified, nodes are sorted based on their Y-coordinates. This is useful in isometric or overhead games.

layer.construct(x, y)

This is an internal function Please use scene.newLayer or layer.newLayer instead.
numberx
X coordinate
numbery
Y coordinate
Returns
layer New layer

layer:deconstruct()

This is an internal function

layer:destroyChildren()

Destroys all of the child nodes.

layer:draw()

This is an internal function

layer:getChild(index)

Returns a child node based on depth index (could be negative).
numberindex
Depth index

layer:getChildDepth(child)

Gets the depth index of a child node.
nodechild
Child node
Returns
number Depth index

layer:insertChild(child)

This is an internal function Adds a new child node to the layer.
nodechild
Child node

layer:newCamera(x, y)

Creates a new camera at the given position. Sets the parent of the new camera to the current node.
numberx
X-coordinate
numbery
Y-coordinate
Returns
camera New camera object

layer:newLayer(x, y)

Creates a new layer at the given position. Sets the parent of the new layer to the current node.
numberx
X-coordinate
numbery
Y-coordinate
Returns
layer New layer object

layer:newSprite(x, y)

Creates a new sprite at the given position. Sets the parent of the new sprite to the current node.
numberx
X-coordinate
numbery
Y-coordinate
Returns
sprite New sprite object

layer:removeChild(child)

This is an internal function Removes an existing child node from the layer.
nodechild
Child node

layer:removeChildren()

Removes all child nodes without destroying them.

layer:reset(x, y)

This is an internal function
numberx
X-coordinate
numbery
Y-coordinate

layer:setChildDepth(child, index)

Sets the depth index of a child node. This depth index may shift as node are added, removed or sorted.
nodechild
Child node
numberindex
Depth index (could be negative)

layer:sort(func)

Sorts the child nodes based on a comparison function. If no comparison function is specified, nodes are sorted based on their Y-coordinates. This is useful in isometric or overhead games.
functionfunc (optional)
Comparison function



camera

Cameras can be placed in the scene and transformed like regular nodes. Cameras can also render contents onto the view object.
node
node:compareDepth(other)This is an internal function. Compares the depth of two nodes, based on their Y-coordinates.
node:deconstruct()This is an internal function
node:destroy()Destroys the node removing it from its parent layer.
node:getDepth()Gets the depth index relative to other nodes in the parent layer.
node:getParent()Gets the current parent layer of the node.
node:getPosition()Gets the position of the node.
node:getRoot()Returns the root layer of the node or nil if the current node does not have a parent.
node:getRotation()Gets the rotation of the node.
node:getScale()Gets the scale of the node.
node:getTransform()Gets the position and rotation of the node.
node:getVisible()Gets the visibility of the node. Non-visible nodes are not drawn at all.
node:localToParent(x, y)Converts a position from local to parent coordinates. The center of the parent layer is its origin.
node:localToRoot(x, y)Converts a position from local to scene coordinates. The origin of the scene is the center of the root layer.
node:localToWindow(x, y)Converts a position from local to window coordinates. This function works only if the root node is a view object or returns nil otherwise.
node:parentToLocal(x, y)Converts a position from parent to local coordinates. The center of the parent layer is its origin.
node:rootToLocal(x, y)Converts a position from scene to local coordinates. The origin of the scene is the center of the root layer.
node:setDepth(index)Sets the depth index relative to other nodes in the parent layer. Setting the depth to 1 will draw the node first, before all others. Setting the depth to 0 will draw the node last, after all others. This depth index may shift as nodes are added, removed or sorted.
node:setParent(parent)Sets the parent layer of the node. All nodes can have just one parent.
node:setPosition(x, y)Sets the position of the node.
node:setRotation(angle)Sets the rotation of the node.
node:setScale(sx, sy)Sets the scale of the node.
node:setTransform(x, y, angle)Sets the position and rotation of the node.
node:setVisible(True)Sets the visibility of the node. Non-visible nodes are not drawn at all.
node:type()Returns the node type as a string
node:windowToLocal(x, y)Converts a position from window to local coordinates. This function works only if the root node is a view object or returns nil otherwise.
camera
camera.construct(x, y)This is an internal function Please use scene.newCamera or layer.newCamera instead.
camera:draw()This is an internal function
camera:getRange()Gets the viewing range of the camera in scene units. Returns zero if no range is specified.
camera:render(view)This is an internal function
camera:reset(x, y)This is an internal function
camera:setRange(width, height)Sets the viewing range of the camera in scene units. The camera node's scale is ignored upon setting a non-zero range. When the viewing range is set to zero, the rendered area is determined by the camera's scale and the dimensions of the view object.

camera.construct(x, y)

This is an internal function Please use scene.newCamera or layer.newCamera instead.
numberx
X coordinate
numbery
Y coordinate
Returns
camera New camera

camera:draw()

This is an internal function

camera:getRange()

Gets the viewing range of the camera in scene units. Returns zero if no range is specified.
Returns
number Range width in scene units
number Range height in scene units

camera:render(view)

This is an internal function
nodeview
View object

camera:reset(x, y)

This is an internal function
numberx
X-coordinate
numbery
Y-coordinate

camera:setRange(width, height)

Sets the viewing range of the camera in scene units. The camera node's scale is ignored upon setting a non-zero range. When the viewing range is set to zero, the rendered area is determined by the camera's scale and the dimensions of the view object.
numberwidth
Range width in scene units
numberheight
Range height in scene units



view

View is a clipped rectangular area where the scene is rendered. Views can be transformed, drawn and shaded.
node
node:compareDepth(other)This is an internal function. Compares the depth of two nodes, based on their Y-coordinates.
node:destroy()Destroys the node removing it from its parent layer.
node:getDepth()Gets the depth index relative to other nodes in the parent layer.
node:getParent()Gets the current parent layer of the node.
node:getRoot()Returns the root layer of the node or nil if the current node does not have a parent.
node:getRotation()Gets the rotation of the node.
node:getScale()Gets the scale of the node.
node:getTransform()Gets the position and rotation of the node.
node:getVisible()Gets the visibility of the node. Non-visible nodes are not drawn at all.
node:localToParent(x, y)Converts a position from local to parent coordinates. The center of the parent layer is its origin.
node:parentToLocal(x, y)Converts a position from parent to local coordinates. The center of the parent layer is its origin.
node:setDepth(index)Sets the depth index relative to other nodes in the parent layer. Setting the depth to 1 will draw the node first, before all others. Setting the depth to 0 will draw the node last, after all others. This depth index may shift as nodes are added, removed or sorted.
node:setParent(parent)Sets the parent layer of the node. All nodes can have just one parent.
node:setRotation(angle)Sets the rotation of the node.
node:setScale(sx, sy)Sets the scale of the node.
node:setTransform(x, y, angle)Sets the position and rotation of the node.
node:setVisible(True)Sets the visibility of the node. Non-visible nodes are not drawn at all.
node:type()Returns the node type as a string
layer
layer:destroyChildren()Destroys all of the child nodes.
layer:getChild(index)Returns a child node based on depth index (could be negative).
layer:getChildDepth(child)Gets the depth index of a child node.
layer:insertChild(child)This is an internal function Adds a new child node to the layer.
layer:newCamera(x, y)Creates a new camera at the given position. Sets the parent of the new camera to the current node.
layer:newLayer(x, y)Creates a new layer at the given position. Sets the parent of the new layer to the current node.
layer:newSprite(x, y)Creates a new sprite at the given position. Sets the parent of the new sprite to the current node.
layer:removeChild(child)This is an internal function Removes an existing child node from the layer.
layer:removeChildren()Removes all child nodes without destroying them.
layer:setChildDepth(child, index)Sets the depth index of a child node. This depth index may shift as node are added, removed or sorted.
layer:sort(func)Sorts the child nodes based on a comparison function. If no comparison function is specified, nodes are sorted based on their Y-coordinates. This is useful in isometric or overhead games.
view
view.construct(x, y, width, height)This is an internal function Please use scene.newView instead.
view:deconstruct()This is an internal function
view:draw()By default, this function draws the view and all of its visible child nodes.
view:getBackground()Gets the background color.
view:getCamera()Gets the camera associated with the view.
view:getDimensions()Gets the dimensions of the view inside the game window.
view:getOrigin()Gets the origin of the view object as ratio values, where 0, 0 is the top-left corner and 1, 1 is the bottom right. The origin of the view is the center or 0.5, 0.5.
view:getPosition()Gets the position of the view inside the application window.
view:getShader()Gets the pixel shader.
view:localToRoot(x, y)Converts a position from local to scene coordinates. The origin of the scene is the center of the root layer.
view:localToWindow(x, y)Converts a position from scene to window coordinates. The origin of the scene is the center of the root layer.
view:reset(x, y, width, height)This is an internal function
view:rootToLocal(x, y)Converts a position from scene to local coordinates. The origin of the scene is the center of the root layer.
view:rootToWindow(x, y)Converts scene coordinates to window coordinates. This function works in conjunction with the currently associated camera.
view:setBackground(red, green, blue, alpha)Sets the background color.
view:setCamera(camera)Sets the camera for the view.
view:setDimensions(width, height)Sets the dimensions of the view inside the game window.
view:setOrigin(ox, oy)Sets the origin of the view object based ratio values, where 0, 0 is the top-left corner and 1, 1 is the bottom right. The default origin of the view is the center or 0.5, 0.5.
view:setPosition(x, y)Sets the position of the view inside the application window.
view:setShader(shader)Sets the pixel shader.
view:windowToLocal(x, y)Converts a position from window to scene coordinates. The origin of the scene is the center of the root layer.
view:windowToRoot(x, y)Converts window coordinates to scene coordinates. This function works in conjunction with the currently associated camera.

view.construct(x, y, width, height)

This is an internal function Please use scene.newView instead.
numberx (optional)
X-position in pixels
numbery (optional)
Y-position in pixels
numberwidth (optional)
Width in pixels
numberheight (optional)
Height in pixels
Returns
view New view object

view:deconstruct()

This is an internal function

view:draw()

By default, this function draws the view and all of its visible child nodes.

view:getBackground()

Gets the background color.
Returns
number Red value (0-1)
number Green value (0-1)
number Blue value (0-1)
number Alpha value (0-1)

view:getCamera()

Gets the camera associated with the view.
Returns
camera camera Camera object

view:getDimensions()

Gets the dimensions of the view inside the game window.
Returns
number Width in pixels
number Height in pixels

view:getOrigin()

Gets the origin of the view object as ratio values, where 0, 0 is the top-left corner and 1, 1 is the bottom right. The origin of the view is the center or 0.5, 0.5.
Returns
number X-ratio from 0 to 1
number Y-ratio from 0 to 1

view:getPosition()

Gets the position of the view inside the application window.
Returns
number X-position in pixels
number Y-position in pixels

view:getShader()

Gets the pixel shader.
Returns
userdata Pixel shader object

view:localToRoot(x, y)

Converts a position from local to scene coordinates. The origin of the scene is the center of the root layer.
numberx
Local X-coordinate
numbery
Local Y-coordinate
Returns
number Scene X-coordinate
number Scene Y-coordinate

view:localToWindow(x, y)

Converts a position from scene to window coordinates. The origin of the scene is the center of the root layer.
numberx
X scene coordinate
numbery
Y scene coordinate
Returns
number X-position in pixels
number Y-position in pixels

view:reset(x, y, width, height)

This is an internal function
numberx
X-position in pixels
numbery
Y-position in pixels
numberwidth
Width in pixels
numberheight
Height in pixels

view:rootToLocal(x, y)

Converts a position from scene to local coordinates. The origin of the scene is the center of the root layer.
numberx
Scene X-coordinate
numbery
Scene Y-coordinate
Returns
number Local X-coordinate
number Local Y-coordinate

view:rootToWindow(x, y)

Converts scene coordinates to window coordinates. This function works in conjunction with the currently associated camera.
numberx
X scene coordinate
numbery
Y scene coordinate
Returns
number X-position in pixels
number Y-position in pixels

view:setBackground(red, green, blue, alpha)

Sets the background color.
numberred
Red value (0-1)
numbergreen
Green value (0-1)
numberblue
Blue value (0-1)
numberalpha (optional)
Alpha value (0-1)

view:setCamera(camera)

Sets the camera for the view.
cameracamera
Camera object

view:setDimensions(width, height)

Sets the dimensions of the view inside the game window.
numberwidth
Width in pixels
numberheight
Height in pixels

view:setOrigin(ox, oy)

Sets the origin of the view object based ratio values, where 0, 0 is the top-left corner and 1, 1 is the bottom right. The default origin of the view is the center or 0.5, 0.5.
numberox
X-ratio from 0 to 1
numberoy
Y-ratio from 0 to 1

view:setPosition(x, y)

Sets the position of the view inside the application window.
numberx
X-position in pixels
numbery
Y-position in pixels

view:setShader(shader)

Sets the pixel shader.
userdatashader (optional)
Pixel shader object

view:windowToLocal(x, y)

Converts a position from window to scene coordinates. The origin of the scene is the center of the root layer.
numberx
X-position in pixels
numbery
Y-position in pixels
Returns
number X scene coordinate
number Y scene coordinate

view:windowToRoot(x, y)

Converts window coordinates to scene coordinates. This function works in conjunction with the currently associated camera.
numberx
X-position in pixels
numbery
Y-position in pixels
Returns
number X scene coordinate
number Y scene coordinate