Making the player move with the map (camera control problem)

Hi,

This is a platform game I am developing.

I am using the following to lock the camera to the player:

 map:setFocus( player ); 

Problem is the player semms not to be a child of the map’s visual object, so the functions of lime moving the map is added to the player’s movement resulting in the player moving double the distance. Collision with objects are also failing, I guess it is because the map’s object coordinates are moved directly into the player.

Is there an inbuilt method to make the player a child of the map or an alternative to fix this issue? [import]uid: 75783 topic_id: 12549 reply_id: 312549[/import]

Look at the “ParallaxAndPlayer” sample, it tells you everything you need to know. [import]uid: 63565 topic_id: 12549 reply_id: 46238[/import]

I have answered this question via email however will also reply here so anyone else can get the answer.

What you need to do is add the player object to the map via:

map:addObject( player )  

Or you can do the same on a specific tile layer object like so:

tileLayer:addObject( player ) [import]uid: 5833 topic_id: 12549 reply_id: 46302[/import]

Somehow, the ParallaxAndPlayer sample doesn’t work for me. I got a empty blue screen. See: http://static.yosteps.com/test/Lime_ParallaxAndPlayer.png

I am using Corona SDK 2011.657 on MacOS. I also build the sample to my iPod and got the same blue screen.

Anyone experienced the same problem? Or any advices would be appreciated. [import]uid: 74421 topic_id: 12549 reply_id: 66617[/import]

Hmm, strange that one. Are you just running the unchanged sample? Are you getting any errors in the terminal at all? [import]uid: 5833 topic_id: 12549 reply_id: 66804[/import]

Hi, I am also having difficulties with camera movements. I’m using Tiled and Physics Editor, and when I put ‘map:setFocus( player );’ in my code so that I can have camera movement, the hit areas of the static physics objects made in Physics Editor (not the physics boxes made in Tiled; they work fine) are all over the place. This only seems to happen when ‘map:setFocus( player );’ is in the code. Any help is greatly appreciated. [import]uid: 66329 topic_id: 12549 reply_id: 71238[/import]

Are the physics objects made in PE getting added to the map object and are they added to the correct layer? [import]uid: 5833 topic_id: 12549 reply_id: 71572[/import]

The objects have been added to the correct layers. I’ve followed the Complex physics objects with PhysicsEditor tutorial exactly as described multiple times. The exact issue is that controlled (or non-controlled) object never interact properly with the custom physics objects when a camera is set up. I used both the “Following an object” and “Sliding the map” options. Just to make sure that it wasn’t me, I used the completed project supplied with the tutorial, re-sized the map then added “Sliding the map” camera controls. The camera effecting the physics is extremely noticeable and only starts when I move the camera.

Am I missing something or is this a bug?
Thanks in advance!

[import]uid: 66329 topic_id: 12549 reply_id: 71756[/import]

Just to check, is your map using Parallax scrolling? [import]uid: 5833 topic_id: 12549 reply_id: 71986[/import]

No. I’m just combining the completed “Animated characters” tutorial with the “Complex physics objects with PhysicsEditor” tutorial.

I’ve also created versions completely from scratch with my own assets. [import]uid: 66329 topic_id: 12549 reply_id: 72023[/import]

Are you able to send me an example of it zipped up to support@justaddli.me and I will take a look at it. Sounds like you’ve found a bug. Darn you :slight_smile: [import]uid: 5833 topic_id: 12549 reply_id: 72274[/import]

Has anyone found a resolution to this issue? My physics properties, whether made in PhysicsEditor or Tiled, stretch when using the map:addObject( player ) variable. [import]uid: 135394 topic_id: 12549 reply_id: 114355[/import]