PDA

View Full Version : platform game - screen scrolls with character



ryrocks
November 25th, 2008, 10:17 PM
..

Kiwi Play
November 26th, 2008, 12:00 AM
You can put everything in a container and move that so that it centers on the character, then just move the character.

ryrocks
November 26th, 2008, 07:01 AM
You can put everything in a container and move that so that it centers on the character, then just move the character.

What do you mean by a container? A movieclip? Is it the same method as I mentioned in my original post? Please explain in more detail

Thanks

Kiwi Play
November 26th, 2008, 03:00 PM
Having everything else move and keeping the character stationary in the center of the screen will cause problems problems later on. You would have to be moving many different layers around the character, making sure they all move in sync, and adjust for their position; for example, if your stage is 800x600, then your character's position is always (400, 300) in the movie, but he's actually somewhere else in the game.

Save the headache and just throw everything in a MovieClip or Sprite, and move the character around like normal; all you need to do then is center the container on the character as the character moves.

pixelsguy
November 26th, 2008, 06:49 PM
to elaborate on kiwi play's post,

put everything into one container movie clip, and any time the character's x position moves, just move the entire movie clip so that, where C = a constant for X offset of the character, say, 400:

containerMC.x = C - containerMC.x.characterMC.x;

so, say, at the start, containerMC.x = 0, and the characterMC is at a local x value of 400, then containerMC.characterMC.x = 400; if characterMC moves 10 pts to the right, contaimerMC.x = 400 -410 = -10; your character will still look like he is at 400, and the level will have moved. Sometimes it looks nice to put a blurfilter on the containerMC if the movement is significant.

ryrocks
November 27th, 2008, 08:47 PM
Cheers Pixelsguy and Kiwi Play, it worked a treat! :-)