How to make a platformer game that camera follows a player?

Hello Masters,

I am very new to corona, I just started learning the SDK for a week. So far I really like corona in developing games, very straight forward. However I have a problem in creating a platformer game like this:  https://play.google.com/store/apps/details?id=com.frogmind.badland

My question is how can i make the camera follows a player with a specific stage bounds like for example on this phaser page: http://phaser.io/examples/v2/input/virtual-gamecontroller

Thanks in advance! 

Perspective is a library that a lot of people use to manage “camera” functionality. However, remember that there is no “Corona camera” that exists in a global sense, so there isn’t a Corona-centric method to handle this. This is good, because once you feel more comfortable with Corona, you can develop your own logic for this that suits your game/app type.

Additionally, if you’re trying to create a platformer, you might want to check out the Dusk library. Again, this is a third-party module with no support from Corona proper, but it’s used widely and has excellent support for being open-source.

https://code.coronalabs.com/code/perspective-virtual-camera-system

https://forums.coronalabs.com/topic/42355-dusk-engine/

Welcome to Corona!!!  Platformer games are pretty easy to do in the grand scale of things. You’re camera question is a very common question and some quick search using either the forum search or google.com for “corona camera” will bring up a bunch of forum threads that discuss this. You will have to weed through a few hits talking about the picture taking camera as opposed to the move the screen around the player camera,  but this is such a popular question the move the player type comes up high in the search results.

Rob

Just to elaborate on what alex@panc has said about there being no “camera” strictly speaking. The simplest way I can explain how to make it appear that the camera is moving in one direction, is to actually move the background/platforms/etc in the opposite direction. 

So if you want the camera to move to the right, then you move the game world to the left.

This community is awesome… I am thankful that I am on the right direction now since I have been banging my head on the api docs and can’t find answers but here you are guys feeding up all the answers for me. Alex@panc, Alan QuizTix, and of course moderator Rob thank you for the answers. I believe the perspective library is a good tool to experiment Thanks a lot guys :slight_smile:

For someone starting out, I’m surprised no one suggested the Composer GUI from Corona:

https://docs.coronalabs.com/composer/

Or Level Helper:

http://www.gamedevhelper.com/

I’ve actually not used either one, but sometimes I feel like it could have saved me some trouble!

Dave

This is a late repost of the same answer I gave in your other thread ( I’d go delete that one ).

There is some overlap with answers above.

REPOST BEGINS:

There are a few camera libraries out there so you should look at several, but they all work on the same principle:

 

  1. Create layering system with display group(s).

 

  1. Create objects, including one object to track (usually the player).

 

  1. Track the object with an enterFrame listener and adjust the position of the group the tracking object is in to keep the tracking object in a specific position or bound.

 

Here is my library with several camera styles and example usages:

 

http://github.com/roaminggamer/RGCamera

 

Again, there are others so I’d do a Google search for “corona sdk camera” and see what pops up.  (Caleb Place has one too:http://gist.github.com/GymbylCoding/8675733) “External link”)

 

Here are the results of a search on GitHub:

 

http://github.com/search?utf8=%E2%9C%93&q=camera+corona

Perspective is a library that a lot of people use to manage “camera” functionality. However, remember that there is no “Corona camera” that exists in a global sense, so there isn’t a Corona-centric method to handle this. This is good, because once you feel more comfortable with Corona, you can develop your own logic for this that suits your game/app type.

Additionally, if you’re trying to create a platformer, you might want to check out the Dusk library. Again, this is a third-party module with no support from Corona proper, but it’s used widely and has excellent support for being open-source.

https://code.coronalabs.com/code/perspective-virtual-camera-system

https://forums.coronalabs.com/topic/42355-dusk-engine/

Welcome to Corona!!!  Platformer games are pretty easy to do in the grand scale of things. You’re camera question is a very common question and some quick search using either the forum search or google.com for “corona camera” will bring up a bunch of forum threads that discuss this. You will have to weed through a few hits talking about the picture taking camera as opposed to the move the screen around the player camera,  but this is such a popular question the move the player type comes up high in the search results.

Rob

Just to elaborate on what alex@panc has said about there being no “camera” strictly speaking. The simplest way I can explain how to make it appear that the camera is moving in one direction, is to actually move the background/platforms/etc in the opposite direction. 

So if you want the camera to move to the right, then you move the game world to the left.

This community is awesome… I am thankful that I am on the right direction now since I have been banging my head on the api docs and can’t find answers but here you are guys feeding up all the answers for me. Alex@panc, Alan QuizTix, and of course moderator Rob thank you for the answers. I believe the perspective library is a good tool to experiment Thanks a lot guys :slight_smile:

For someone starting out, I’m surprised no one suggested the Composer GUI from Corona:

https://docs.coronalabs.com/composer/

Or Level Helper:

http://www.gamedevhelper.com/

I’ve actually not used either one, but sometimes I feel like it could have saved me some trouble!

Dave

This is a late repost of the same answer I gave in your other thread ( I’d go delete that one ).

There is some overlap with answers above.

REPOST BEGINS:

There are a few camera libraries out there so you should look at several, but they all work on the same principle:

 

  1. Create layering system with display group(s).

 

  1. Create objects, including one object to track (usually the player).

 

  1. Track the object with an enterFrame listener and adjust the position of the group the tracking object is in to keep the tracking object in a specific position or bound.

 

Here is my library with several camera styles and example usages:

 

http://github.com/roaminggamer/RGCamera

 

Again, there are others so I’d do a Google search for “corona sdk camera” and see what pops up.  (Caleb Place has one too:http://gist.github.com/GymbylCoding/8675733) “External link”)

 

Here are the results of a search on GitHub:

 

http://github.com/search?utf8=%E2%9C%93&q=camera+corona