Moving the camera

Hello,

I am trying to move the camera on the 2d coordinates. However, whenever i search for camera api’s, i only get the actual camera, the one you take photo’s with. I am not sure what else a game camera could be called.

Basically i just want to do:

camera.setPosition(x, y);

Can anybody point me in the right direction?

The concept of a camera is reliant upon the use of display groups (or other containers).

The most basic camera code operates as follows:

  1. Place objects in a group.

  2. Designate a ‘focus’ object.  This is the object the camera is tracking.

  3. When the ‘focus’ object moves in one direction, the group is moved in an equal and opposite direction.  This essentially makes it seem like the objects in the group are moving around the ‘focus’ object while the focus object stays stationary.

SSK2 comes with several basic cameras.

As well, I’m sure others will suggest other solutions.

Im confused… isnt controlling a camera like a very basic thing to be able to do?

Do I really have to do it in a hacky way?

Hi.  If you decide to investigate SSK2, be warned: "It assumes you are already competent with Lua programming and Corona SDK fundamentals such as object creation, use of groups, enterFrame listener, touch listeners, collision listeners, et al. "

Also, and a lot of folks miss this, the kit comes with a validation suite that demos many (not all) of the features:

https://github.com/roaminggamer/SSK2

Here are the validation tests for each of the cameras: https://github.com/roaminggamer/SSK2/tree/master/validation/tests/camera

Here is a VERY OLD video of SSK2 running many of the validation tests (there are many more today): 

https://www.youtube.com/watch?v=NnGKLrJiYN4

Thank you for the replies. I was looking for a simple camera movement on a 2d plane. A lot of other engines do support that kind of api. However, I might be able to get it working via the ‘move all objects on screen to fake a camera’ effect, but I still think this is very weird and will probably result in unexpected bugs.

For example, imagine super mario 64. The camera there doesnt work like moving the whole world while mario is in it, just to control a camera?

I still feel like I am missing something here… 

Is there really no way to change what the engine’s viewport is? Without moving the whole world again?

For some context, i am making a 2d action platformer game, where the player traverses the 2d world from the side

I’ve decided that many of my responses were pointless and have removed all but the original two useful answer.

The concept of a camera is reliant upon the use of display groups (or other containers).

The most basic camera code operates as follows:

  1. Place objects in a group.

  2. Designate a ‘focus’ object.  This is the object the camera is tracking.

  3. When the ‘focus’ object moves in one direction, the group is moved in an equal and opposite direction.  This essentially makes it seem like the objects in the group are moving around the ‘focus’ object while the focus object stays stationary.

SSK2 comes with several basic cameras.

As well, I’m sure others will suggest other solutions.

Im confused… isnt controlling a camera like a very basic thing to be able to do?

Do I really have to do it in a hacky way?

Hi.  If you decide to investigate SSK2, be warned: "It assumes you are already competent with Lua programming and Corona SDK fundamentals such as object creation, use of groups, enterFrame listener, touch listeners, collision listeners, et al. "

Also, and a lot of folks miss this, the kit comes with a validation suite that demos many (not all) of the features:

https://github.com/roaminggamer/SSK2

Here are the validation tests for each of the cameras: https://github.com/roaminggamer/SSK2/tree/master/validation/tests/camera

Here is a VERY OLD video of SSK2 running many of the validation tests (there are many more today): 

https://www.youtube.com/watch?v=NnGKLrJiYN4

Thank you for the replies. I was looking for a simple camera movement on a 2d plane. A lot of other engines do support that kind of api. However, I might be able to get it working via the ‘move all objects on screen to fake a camera’ effect, but I still think this is very weird and will probably result in unexpected bugs.

For example, imagine super mario 64. The camera there doesnt work like moving the whole world while mario is in it, just to control a camera?

I still feel like I am missing something here… 

Is there really no way to change what the engine’s viewport is? Without moving the whole world again?

For some context, i am making a 2d action platformer game, where the player traverses the 2d world from the side

I’ve decided that many of my responses were pointless and have removed all but the original two useful answer.