Levelhelper 2 Corona SDK Tutorial Part 6

Ok so where we left of lat time is that I had make a mistake around the position of the camera in relation to the node it was following. I had proposed that you govern it’s placement by restricting the gameworld – whilst technically possible, not a good idea really. So the correct way is to use the Important Area Width & Height settings. In my defence I thing Bogdan could have made this a bit clearer! So we need to change these values to 0

set important area

now when we publish the scene and play in the Corona simulator our camera is centered on the player object

camera centeres

Corona SDK Coding

Ok so now the programming bit. Levelhelper will allow you to layout scenes, adjust physics and do animations but in order to actually make a game you will still need to be able to programming with the Corona SDK. What we are going to do is move our player object to the right on every frame. At this point I will point out that this tutorial is not a Lua or Corona SDK programming tutorial… Erm… Well it is but only from the integration with Levelhelper perspective.

The first thing we are going to do is to name our player object. So select it then go to the Properties Inspector and in the Unique Name field type: player

unique name field

This is how we will reference the object in code. On the left-hand pain make sure that the Project Navigator is selected

project navigator

Then the in the file list double-click on TestScene.lua (or whatever name you chose for you scene).

level helper code editor

Now you should see Levelhelper’s code editor open up. This is very cool and quite similar to something like Sublime or Brackets.

Get a reference to our player object

First we need to declare a forward reference to our object. So just below the line

local lhScene = nil;


local player = nil;

In the function scene:show in the if phase==”will” condition type this just below the line┬ásceneGroup:insert(lhScene);

player = lhScene:getChildNodeWithUniqueName(“player”);

Now we have a reference to our player object.

Making our player move

Once we have obtained a reference to our player object we are in pure Corona SDK programming territory. So we are first going to declare an update function

function update(event)


inside this function we will do something like this:

player.x = player.x + 1

And then don’t forget to add the listener

Runtime:addEventListener(“enterFrame”, update)

Now when you publish and run the app your player object should slowly move to the right (you may want to set the bounce to zero on the player object).

In the next tutorial we’ll get into sprite sheets.




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.