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
now when we publish the scene and play in the Corona simulator our camera is centered on the player object
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
This is how we will reference the object in code. On the left-hand pain make sure that the Project Navigator is selected
Then the in the file list double-click on TestScene.lua (or whatever name you chose for you scene).
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
inside this function we will do something like this:
player.x = player.x + 1
And then don’t forget to add the listener
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.