LHScene Reference

LHScene.lua

Overview

LHScene is used to load a level file into Corona SDK engine. End users will have to use this class in order to load a level done with LevelHelper 2 into Corona SDK.

local LHScene = require("LevelHelper2-API.LHScene");
local lhScene = LHScene:initWithContentOfFile("publishFolder/level01.json");

Conforms to:

LHNodeProtocol

Instance Methods

cloneNodeWithUniqueName

local  cloneNodeWithUniqueName(uniqueName)
Parameters
uniqueName

The unique name of the object already in the scene.

Return Value

A new node object or nil if no node with unique name is found in the scene.

local newNodeObj = lhScene:cloneNodeWithUniqueName("uniqueNameOfNodeInScene");
    
newNodeObj.x = 100;
newNodeObj.y = 200;

--where lhScene is the object returned by LHScene:initWithContentOfFile("...");

Discussion

Takes the info of the node in the scene with unique name and creates a clone.

The new node parent will be the same as the initial node.

Note that the x and y position values for the new node needs to be given in the parent coordinate system.

The new cloned object unique name will be the the old object name + "Clone" e.g. "[uniqueName]Clone".

Only the cloned object unique name gets changed, all children of the cloned object will have the same name as the original node.

If you need to retrive a child from a cloned object use "getChildNodeWithUniqueName" on the cloned object itself and not on the scene object.

Declared In
LHScene.lua

disableCollisionHandling

local  disableCollisionHandling()
Discussion

Disable the use of LevelHelper API collision handling

Declared In
LHScene.lua

enableCollisionHandling

local  enableCollisionHandling()
Discussion

Enable the use of LevelHelper API collision handling.

The following events will be available once you register to them.

lhScene:addEventListener("didBeginContact", scene); --lhScene is your LHScene object
lhScene:addEventListener("didEndContact", scene); --scene is your corona scene
function scene:didBeginContact(event)

    local contactInfo = event.object;
    
    print("did BEGIN contact with info......................................................");
    print("Node A: " .. tostring(contactInfo.nodeA));
    print("Node A Shape name: " .. contactInfo.nodeAShapeName);
    print("Node A Shape id: " .. contactInfo.nodeAShapeID);
    print("Node B: " .. tostring(contactInfo.nodeB));
    print("Node B Shape name: " .. contactInfo.nodeBShapeName);
    print("Node B Shape id: " .. contactInfo.nodeBShapeID);
end
function scene:didEndContact(event)

    local contactInfo = event.object;

    print("did END contact with info......................................................");
    print("Node A: " .. tostring(contactInfo.nodeA));
    print("Node A Shape name: " .. contactInfo.nodeAShapeName);
    print("Node A Shape id: " .. contactInfo.nodeAShapeID);
    print("Node B: " .. tostring(contactInfo.nodeB));
    print("Node B Shape name: " .. contactInfo.nodeBShapeName);
    print("Node B Shape id: " .. contactInfo.nodeBShapeID);

end

Declared In
LHScene.lua

getBackUINode

local  getBackUINode()
Discussion

Get the back ui node from the scene.

Declared In
LHScene.lua

getGameWorldNode

local  getGameWorldNode()
Discussion

Get the game world node from the scene.

Declared In
LHScene.lua

getGameWorldRect

local  getGameWorldRect()
Discussion

Returns the game world rectangle or nil if it was not specified. A table of format {origin={x = 10, y = 10}, size={width=100, height=100}};

Declared In
LHScene.lua

getUINode

local  getUINode()
Discussion

Get the front ui node from the scene.

Declared In
LHScene.lua

initWithContentOfFile

  initWithContentOfFile(jsonFile)
Parameters
jsonFile

The path to the json file.

Discussion

This functions creates the LHScene object that loads the level file from a json specified by the path.

Declared In
LHScene.lua

tracedFixturesWithUUID

local  tracedFixturesWithUUID(uuid)
Parameters
uuid

The shape fixture unique identifier

Discussion

Get the physical shape fixture information with a specific unique identifier.

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

Back to top

Copyright © VLADU BOGDAN DANIEL PFA.