Hi,
After spending some frustrating hours, I am resorting to asking in this forum for opinion of experts out there.
I have a map.json file and I am using Berrys Tiled engine to load it.
How to make sure the camera follows the character ?
-
The character when moves to the right, the camera should follow it
-
Similar behavior when character moves up or down
-
The map.x should move opposite to the direction of player.x so that there is a feeling that the camera is on the character
But how exactly to do it?
I tried :
local function movecharacter (event)
myAnimation.x = myAnimation.x + motionx;
myAnimation.y = myAnimation.y + motiony;
if (myAnimation.x > 300) then
camera.x = myAnimation.x + display.contentCenterX
end
camera.y = myAnimation.y - display.contentCenterY
print (camera.x)
end
Runtime:addEventListener(“enterFrame”, movecharacter)
the map moves out of the left edge…and moves with the character…confused…how to implement this.