At the moment i’ve got a camera to follow the player as it traverses the level. THis is good but i would like the camera to be centered on the player as it moves. This is bceuase i’d like to zoom in on the player to make the game look better. Right now when i play my game it looks like this:
Below is the code in the camera script:
function init(self)
msg.post("camera#level1", "acquire_camera_focus")
end
function on_message(self, message_id, message, sender)
if message_id == hash("follow") then
go.set_parent(".", sender)
go.set_position(vmath.vector3(512, 382.5, 0))
elseif message_id == hash("unfollow") then
go.set_parent("camera#level1", nil, true)
end
end
This is the code in the player script:
if action_id == hash("touch") and action.pressed then
self.follow = not self.follow
if self.follow then
msg.post("camera#level1", "follow")
else
msg.post("camera#level1", "unfollow")
end
end
Do you guys know how i cen get the camera to center on the player. I’ve been trying some things out and i think the answer may lie in the line of code: go.set_position(vmath.vector3(512, 382.5, 0)). Right now its set to 1/2 the aspect ratio which i thought would cause it to be in the center but evidently not. I also tried to use the URL for the player sprite but this didn’t seem to help?