LHNodeProtocol Reference

LHNodeProtocol.lua

Overview

Most of the LevelHelper 2 nodes conforms to this protocol.

Instance Methods

addChild

local  addChild(child)
Parameters
child

The node that will be added as child.

Discussion

Add a child node.

Declared In
LHNodeProtocol.lua

getAnchor

local  getAnchor()
Discussion

Get the node anchor as a table {x = 0.5, y = 0.5}

Declared In
LHNodeProtocol.lua

getChildAtIndex

local  getChildAtIndex(index)
Parameters
index

The index of the child to be returned

Discussion

Returns the children at a specific index

Declared In
LHNodeProtocol.lua

getChildNodeWithUniqueName

local  getChildNodeWithUniqueName(name)
Parameters
name

The node unique name to look for inside the children of the current node.

Discussion

Get the node with the unique name inside the current node.

Declared In
LHNodeProtocol.lua

getChildNodeWithUUID

local  getChildNodeWithUUID(_uuid_)
Parameters
<em>uuid</em>

The node unique identifier to look for inside the children of the current node.

Discussion

Get the node with the unique identifier inside the current node.

Declared In
LHNodeProtocol.lua

getChildren

local  getChildren()
Discussion

Returns the display group of this node (Retuns the children). Because corona does not have a modern children hierachy this is simulated using display groups. Each node its either a display group directly or has a display group added at a 0,0 position of the node. Via enterFrame notification children get updated with correct transformation. Maybe in the future Corona SDK will support a modern gaming objects hierarchy.

Declared In
LHNodeProtocol.lua

getChildrenOfProtocol

local  getChildrenOfProtocol(protocolType)
Parameters
protocolType

A protocol class type. A string value with the name of one of the available protocols "LHNodeProtocol", "LHAnimationsProtocol", "LHJointsProtocol", "LHPhysicsProtocol"

Discussion

Returns all children nodes that are of specified class type. A table with objects.

Declared In
LHNodeProtocol.lua

getChildrenOfType

local  getChildrenOfType(objType)
Parameters
objType

A class type. A string value with the name of the type e.g "LHSprite", "LHNode"

Discussion

Returns all children nodes that are of specified class type. A table with objects.

Declared In
LHNodeProtocol.lua

getChildrenWithTags

local  getChildrenWithTags(tagsTable, any)
Parameters
tagsTable

A table of strings containing tag names.

any

Specify if all or just one tag value of the node needs to be in common with the tagsTable passed as argument to this function.

Discussion

Returns all children nodes that have the specified tag values.

Declared In
LHNodeProtocol.lua

getNumberOfChildren

local  getNumberOfChildren()
Discussion

Returns the number of children this node has. A number value

Declared In
LHNodeProtocol.lua

getParent

local  getParent()
Discussion

Get the node parent object

Declared In
LHNodeProtocol.lua

getPosition

local  getPosition()
Discussion

Get the node position as a table {x = 100, y = 100}

Declared In
LHNodeProtocol.lua

getProtocolName

local  getProtocolName()
Discussion

Get the node protocol type. A string value. e.g "LHNodeProtocol", "LHAnimationsProtocol", "LHJointsProtocol", "LHPhysicsProtocol"

Declared In
LHNodeProtocol.lua

getScene

local  getScene()
Discussion

Get the node LHScene object

Declared In
LHNodeProtocol.lua

getTags

local  getTags()
Discussion

Returns a table of strings representing the tags assigned on this node.

Declared In
LHNodeProtocol.lua

getType

local  getType()
Discussion

Get the node type. A string value. e.g "LHSprite", "LHNode", "LHBezier" ...

Declared In
LHNodeProtocol.lua

getUniqueName

local  getUniqueName()
Discussion

Get the node unique name. A string value.

Declared In
LHNodeProtocol.lua

getUserProperty

local  getUserProperty()
Discussion

Returns the user property object assigned to this node or null.

Declared In
LHNodeProtocol.lua

getUUID

local  getUUID()
Discussion

Get the node unique identifier. A string value.

Declared In
LHNodeProtocol.lua

loadChildrenForNodeFromDictionary

  loadChildrenForNodeFromDictionary(prntNode, dict)
Parameters
filename

The path to the json file.

base

Optional parametter. Where it should look for the file. Default is system.ResourceDirectory.

Discussion

Loads json file and returns contents as a string.

Declared In
LHNodeProtocol.lua

pathMovementGetCurrentRepetition

local  pathMovementGetCurrentRepetition()
Return Value

A number value.

Discussion

Get how many times the movement was repeated on the path since started. This counter is reset only when calling pathMovementRestart().

Declared In
LHNodeProtocol.lua

pathMovementGetDirection

local  pathMovementGetDirection()
Return Value

A number value. A positiv value means object is moving on path from first to last point. A negative value means object is moving on path from last to first point.

Discussion

Get the path movement direction.

Declared In
LHNodeProtocol.lua

pathMovementGetFlipScaleXAtEnd

local  pathMovementGetFlipScaleXAtEnd()
Discussion

Get if the object xScale is flipped when path movement reaches an end point.

Declared In
LHNodeProtocol.lua

pathMovementGetFlipScaleYAtEnd

local  pathMovementGetFlipScaleYAtEnd()
Discussion

Get if the object yScale is flipped when path movement reaches an end point.

Declared In
LHNodeProtocol.lua

pathMovementGetIsPingPong

local  pathMovementGetIsPingPong()
Return Value

A boolean value.

Discussion

Get if path movement is ping pong.

Declared In
LHNodeProtocol.lua

pathMovementGetPlaying

local  pathMovementGetPlaying()
Return Value

A boolean value.

Discussion

Find if the path movement is currently playing or not.

Declared In
LHNodeProtocol.lua

pathMovementGetRepetitions

local  pathMovementGetRepetitions()
Return Value

A number value. A 0 value means the path is looping.

Discussion

Get the number of path movement repetitions.

Declared In
LHNodeProtocol.lua

pathMovementGetUseOrientation

local  pathMovementGetUseOrientation()
Discussion

Get if the object moving on the path is rotating to match the path trajectory.

Declared In
LHNodeProtocol.lua

pathMovementPrepareOnBezier

local  pathMovementPrepareOnBezier(bezierObject)
Parameters
bezierObject

The bezier object of which shape will be used to create the movement of the node.

local bezierObject          = lhScene:getChildNodeWithUniqueName("bezierNodeName");
local objectToMoveOnPath    = lhScene:getChildNodeWithUniqueName("objectNodeName");
objectToMoveOnPath:pathMovementPrepareOnBezier(bezierObject);
Adding path movement has ended event listener
--somewhere at the beginning of your scene file add the following method
function scene:LHPathMovementHasEndedPerObjectNotification(event)
        print("did end path movement on object " .. tostring(event.object) .. " name: " .. event.object:getUniqueName());   
    end

--adding the event lister
objectToMoveOnPath:addEventListener( "LHPathMovementHasEndedPerObjectNotification", scene )

Discussion

Prepare movement on a bezier object.

Declared In
LHNodeProtocol.lua

pathMovementRestart

local  pathMovementRestart()
Discussion

Put the object at the initial path movement starting point and resets repetitions count.

Path movement play/pause state will not be changed.

Declared In
LHNodeProtocol.lua

pathMovementSetDirection

local  pathMovementSetDirection(value)
Parameters
value

A number value. A positiv value means the object will move on path from first to last point. A negative value means from last to first point.

Discussion

Set the path movement direction.

Declared In
LHNodeProtocol.lua

pathMovementSetDuration

local  pathMovementSetDuration(value)
Parameters
value

A number value. In seconds.

Discussion

Set the duration it should take for the object to travel from the beginning to the end of the path.

If path movement is set as ping pong the time to travel begin -> end -> begin will be double.

Declared In
LHNodeProtocol.lua

pathMovementSetFlipScaleXAtEnd

local  pathMovementSetFlipScaleXAtEnd(value)
Parameters
value

A bolean value.

Discussion

Set if the object xScale should be flipped when the path movement reaches an end point.

This is useful for when orienting an object on the path and the movement changes direction.

Declared In
LHNodeProtocol.lua

pathMovementSetFlipScaleYAtEnd

local  pathMovementSetFlipScaleYAtEnd(value)
Parameters
value

A bolean value.

Discussion

Set if the object yScale should be flipped when the path movement reaches an end point.

This is useful for when orienting an object on the path and the movement changes direction.

Declared In
LHNodeProtocol.lua

pathMovementSetIsPingPong

local  pathMovementSetIsPingPong(value)
Parameters
value

A boolean value.

Discussion

Set if the movement on the path should ping pong. E.g Move from beginning to end to beginning. If you enable ping pong and use a specific number of path movement repetitions, you should double the repetitions number.

Declared In
LHNodeProtocol.lua

pathMovementSetPlaying

local  pathMovementSetPlaying(value)
Parameters
value

A true or false value.

Discussion

Play or pause the path movement if it was previously prepared using pathMovementPrepareOnBezier method.

Declared In
LHNodeProtocol.lua

pathMovementSetRepetitions

local  pathMovementSetRepetitions(value)
Parameters
value

A number value. A value of 0 means the path should loop until it is stopped manually using pathMovementSetPlaying(false);

Discussion

Set how many times the path should move until it pause itself.

Declared In
LHNodeProtocol.lua

pathMovementSetUseOrientation

local  pathMovementSetUseOrientation(value)
Parameters
value

A bolean value.

Discussion

Set if the object moving on the path should rotate to have the same orientation as the path.

The object orientation starts from the initial angle of the object when the path movement was prepared.

Declared In
LHNodeProtocol.lua

removeChild

local  removeChild(child)
Discussion

Removes a child node

Declared In
LHNodeProtocol.lua

setAnchor

local  setAnchor(x, y)
Parameters
x

The new x anchor value

y

The new y anchor value

Discussion

Set the node x and y anchor values

Declared In
LHNodeProtocol.lua

setAnchorByKeepingPosition

local  setAnchorByKeepingPosition(x, y)
Parameters
x

The new x anchor value

y

The new y anchor value

Discussion

Set the node x and y anchor by keeping the position of the node on screen in the same place.

Declared In
LHNodeProtocol.lua

setPosition

local  setPosition(value)
Parameters
value

The new position value. A table like {x =100, y = 200}

Discussion

Set the node position

Declared In
LHNodeProtocol.lua

setRotation

local  setRotation(angle)
Parameters
angle

The new rotation value

Discussion

Set the node rotation

Declared In
LHNodeProtocol.lua

setScale

local  setScale(xScale, yScale)
Parameters
xScale

The new x scale value

yScale

The new y scale value

Discussion

Set the node x and y scales values

Declared In
LHNodeProtocol.lua
Last updated: 2015-3-15

Back to top

Copyright © VLADU BOGDAN DANIEL PFA.