Easy Game Camera Control

I am having difficulties controlling the game camera. I know in the Game Salad days there was a great way to assign the camera to an object and do everything through that. In Corona I have tried to simulate that by always creating a camera object. Unfortunately it’s not so easy telling all the other display.Groups what to do.

For example if I want my main character to stay in the center of the screen or move slowly towards the right of the screen, this gets very complicated.

Does anyone have a good methodology to implement the Game Salad type of Camera assignment, so that parallaxes and camera bounds are automatically translated and respected?

Thanks
[import]uid: 8192 topic_id: 5963 reply_id: 305963[/import]

Don’t know anything about Game Salad, but a standard way of creating a camera is to put all components into one final group. Items move, parallax scrolling etc occurs within that group. The main character is then tracked by checking its position in the main “camera” group and scrolling that group accordingly.

Think of it like a very wide screen with something moving across it. You sit in one position and the screen is moved so the character stays in front of you. [import]uid: 3953 topic_id: 5963 reply_id: 21348[/import]

what i did was i looked at the egg smash sample code because the have a working camera that follows the boulder, i followed what they did and it works great in my game also. [import]uid: 19620 topic_id: 5963 reply_id: 22103[/import]

Thanks for your replies. I am already adopting the method used in EggBreaker. All in one of multiple groups and move at enterframe. This is easy for linear movements but not for non linear.

Look at Mega Jump for example.(It’s free) When the little guy gets a boost he moves up a little on the screen with some easing (probably quadratic) he then drops back to the center of the screen. This type of movement could be easily repeated using the transition.to function, I am just perplexed on how to do that, since I can’t put that in the enter frame.

Do you see what I mean? [import]uid: 8192 topic_id: 5963 reply_id: 22350[/import]

Yea, i got my vertical and horizontal camera moving smooth by using the eggbreaker. the eggbreaker only does horizontal so i did some testing to figure it out myself. So i declared a y variable along with the x, so…

game.x = 0  
game.y = 0  
  
local function moveCamera()  
 if (Object.x \> 80 and Object.x \< 11000) then  
 game.x = -Object.x + 80  
 end  
  
 if (Object.y \> 220 and Object.y \< 3000) then  
 game.y = -Object.y + 220  
 end  
  
 if (Object.y \< 220 and Object.y \< 3000) then  
 game.y = -Object.y + 220  
  
 end  
  
 end  

and in this instance for my game i only move from to the right, up and down, otherwise you could add another line of code in your function. that should help!

ps. i just reread your post and im pretty sure i didnt answer your question at all haha, sorry im not sure how to do the easing, i havent made it that far yet. anyways my response was basically how to have your camera follow your character vertically as well as horizontal [import]uid: 19620 topic_id: 5963 reply_id: 22371[/import]