Please Help : Character goes out of the screen

Hi,
I am trying to create a replica of a flash game called hanger. Its a side-scrolling platformer style game. (you can find it on Google ).I had to move my character toward the right.(like mario) I think this can my done only by fixing the character in a position and move the background and other game objects to the left so that it feels like the character moves towards the right.
My work so far :
I have created the roofs, background and placed the character in the center of the screen and make it fall (gravity). the objective of the game is to swing the character without making it fall by clinging to the roof by a rope.when the player touches the screen the character attaches itself to the roof with a rope and make it swing with an accelerometer. and when the player releases his finger the rope disappears. The same way the character swings on till it reaches the end of the level.
The Problem :
When the character moves (while swinging) the floor is moved the same distance in the opposite direction. I coded this in runtime eventlistener. Now the problem is that character ultimately moves out of the screen(towards the right) please help me solve this . Is there any function that will focus on the character and centralize it irrespective of where it moves. [import]uid: 76873 topic_id: 15433 reply_id: 315433[/import]

maybe the camera module is something for you?
http://developer.anscamobile.com/code/camera

[import]uid: 70635 topic_id: 15433 reply_id: 57054[/import]

Sorry.I couldn’t understand how the module works and how to use it . But i think it deals with something related to moving background layers. I need help on centralizing the character. There should be some way to do it. This is a logic that is required for most of the platforming games out there. I wonder how they do it :frowning:
And thank you for your response. [import]uid: 76873 topic_id: 15433 reply_id: 57057[/import]

Anand,
cannot see what you have done, but let me give you this thing to think about. Instead of moving the character, how about pinning the main character in the middle of the screen and moving the rest of the scenery left/right/up or down to give the illusion of the character always being centred?

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 15433 reply_id: 57066[/import]

the camera module can (almost) do what a real life camera can: focus an object, zooming and panning. well, it’s quite rudimentary but it should work for you.

build your level and make the camera show only a part of it

Camera:setScale( x, y )  

then you update your camera to show the coordinates of your character

Camera:setPosition( character.x, character.y )  

look at the sample and the lib and you’ll understand…

hope that helps
-finefin [import]uid: 70635 topic_id: 15433 reply_id: 57077[/import]

Thank you Jayant and Canupa
That was helpful.Got it now :slight_smile: All I had to do was put all the game elements into a group and move them altogether. I will give the camera module a try. I might be needing it in the future.
Thank you guys :slight_smile: [import]uid: 76873 topic_id: 15433 reply_id: 57209[/import]