Eggs will be falling in all different areas of the screen from the sky. Let's prepare our main character to move through all potential areas on te screen.
Set up a new local function called
moveChar()
with anevent
parameter.local moveChar = function(event)
Add in the accelerometer movement for the character.
charObject.x = display.contentCenterX - (display.contentCenterX * (event.yGravity * 3))
Create character boundaries where they moves on the screen. This enables the character to stay within the game screen and not go past the offscreen boundaries.
if((charObject.x - charObject.width * 0.5) < 0) then charObject.x = charObject.width * 0.5 elseif((charObject.x + charObject.width * 0.5) > display.contentWidth) then charObject.x = display.contentWidth - charObject.width * 0.5 end end