Forum Topic: Sidescrolling Platformer Help

(121 views • 6 replies)

This topic is 1 page long.

<< < > >>
Expressionless

TazarTheYoot

Reply To Post Reply & Quote

Posted at: 1/10/09 10:21 PM

TazarTheYoot DARK LEVEL 04

Sign-Up: 10/18/07

Posts: 43

I've got the makings of quite a nice platformer, but I can't seem to make it sidescroll. I've got all the player movements in place and everything, I just want to know how to make the screen scroll when the player gets within a certain distance of the side of the screen.


None

ShirkDeio

Reply To Post Reply & Quote

Posted at: 1/10/09 10:26 PM

ShirkDeio LIGHT LEVEL 16

Sign-Up: 03/29/07

Posts: 989

Kind of like this:

if((character._x < 100 && dir == -1) || (character._x > Stage.width - 100 && dir == 1)) {
level._x -= speed * dir;
} else {
character._x += speed * dir;
}

If the character is by the left side and going left, or by the right side and going right, then move the level. Otherwise, move the character. In the first part, you'll have to put other things you want to move (i.e. enemies or whatnot).

I am a servant of the Most High God
The Hanging Collab || The Legend of Newgrounds (Game) || Crystal Rays (Song)


None

I-smel

Reply To Post Reply & Quote

Posted at: 1/10/09 10:31 PM

I-smel NEUTRAL LEVEL 01

Sign-Up: 03/02/06

Posts: 1,260

onEnterFrame=function(){
if(_root.guy._x>500){
_root._x++;
}
}

if the guy's further along than 500, move the stage to the right. You wouldn't think _root._x was an actual thing but it is.


None

TazarTheYoot

Reply To Post Reply & Quote

Posted at: 1/10/09 10:52 PM

TazarTheYoot DARK LEVEL 04

Sign-Up: 10/18/07

Posts: 43

Hmm, neither of those work.


None

layzergun

Reply To Post Reply & Quote

Posted at: 1/11/09 01:14 PM

layzergun NEUTRAL LEVEL 03

Sign-Up: 10/05/08

Posts: 32

Use this http://www.oreillynet.com/pub/a/javascri pt/2004/08/17/flashhacks.html?page=2
It's a cool AS2 camera that shows everything through a rectangle or other shape.


None

EvanHayes

Reply To Post Reply & Quote

Posted at: 1/11/09 01:47 PM

EvanHayes DARK LEVEL 11

Sign-Up: 01/13/07

Posts: 1,833

use a while loop it works better and can handle any speed

while(_x>400){
_root.ground._x--
_root.player._x--
}
while(_x<100){
_root.ground._x++
_root.player._x++
}

that is extremely simplified but uses no variables so i like that better.

Grah i feel so unknown, SK8MORE god damn :/ EvanHayes seems like a much more serious name than sk8more,so i changed it.


None

ShirkDeio

Reply To Post Reply & Quote

Posted at: 1/13/09 09:49 AM

ShirkDeio LIGHT LEVEL 16

Sign-Up: 03/29/07

Posts: 989

At 1/10/09 10:52 PM, TazarTheYoot wrote: Hmm, neither of those work.

It works perfectly for me, so you just don't know how to implement it.

I am a servant of the Most High God
The Hanging Collab || The Legend of Newgrounds (Game) || Crystal Rays (Song)


All times are Eastern Standard Time (GMT -5) | Current Time: 07:14 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!