Be a Supporter!
gameObject
gameObject
  • Member since: Jan. 4, 2012
  • Offline.
Forum Stats
Member
Level 03
Game Developer
Side scrolling? Nov. 4th, 2012 @ 03:14 AM Reply

Hi,

In the process of creating a 2d sidescroller beat 'em up.

Can anyone give me tips on how to side scroll through a level?

I would like my level to scroll in segments, meaning the level won't scroll unless all the enemies of a wave are destroyed.

fight ---> scroll ---> fight ---> scroll --->boss

Cheers

Ongokiller50
Ongokiller50
  • Member since: Jul. 6, 2008
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Side scrolling? Nov. 4th, 2012 @ 04:01 AM Reply

I recommend using a vcam to 'scroll'. It's fast and simple.

"level won't scroll unless all the enemies of a wave are destroyed"
Put an invisible wall and the 'player' can only collide with this wall.
and For the camera to stop scrolling put something like this

while (vcam.x > invisible_wall.x){
vcam.x--
}

or just stop the camera moving codes and put it on a fixed position.

To disable this invisible wall.
Say like you need 10 kills to pass
When you kill an enemie.

Kills += 1
if (Kills >= 10 && invisible_wall.parent != null){
removeChild(invisible_wall)
}

and stop the other codes that access 'invisible_wall' as well like this.
if (invisible_wall != null){
//what ever.....
}


Den

Ongokiller50
Ongokiller50
  • Member since: Jul. 6, 2008
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Side scrolling? Nov. 4th, 2012 @ 04:03 AM Reply

By The Way,my examples are in AS3


Den

gameObject
gameObject
  • Member since: Jan. 4, 2012
  • Offline.
Forum Stats
Member
Level 03
Game Developer
Response to Side scrolling? Nov. 4th, 2012 @ 04:19 AM Reply

thanks for the reply man, although I have heard that v-cams have some pretty bad flaws.

64base
64base
  • Member since: Apr. 18, 2012
  • Offline.
Forum Stats
Member
Level 02
Programmer
Response to Side scrolling? Nov. 4th, 2012 @ 04:41 AM Reply

At 11/4/12 04:19 AM, gameObject wrote: thanks for the reply man, although I have heard that v-cams have some pretty bad flaws.

Does it? What flaws exactly?


.

gameObject
gameObject
  • Member since: Jan. 4, 2012
  • Offline.
Forum Stats
Member
Level 03
Game Developer
Response to Side scrolling? Nov. 4th, 2012 @ 05:31 AM Reply

It takes up a lot of memory and makes games slow for one

Sandremss128
Sandremss128
  • Member since: Aug. 22, 2009
  • Offline.
Forum Stats
Supporter
Level 11
Programmer
Response to Side scrolling? Nov. 4th, 2012 @ 06:24 AM Reply

If you have tightly coupled objects in your game, Vcam can screw them over by adjusting properties like x, y, width, height and the like.
So if you use hitTestPoint and you use the x and y positions of a movieclip the result can change because of the Vcam. You never want your camera to alter any game data.

Solution to this is to abstract your game data so that the visual representation is independent from internal game data, or simply drop the Vcam and implement your own.

JoSo
JoSo
  • Member since: Sep. 7, 2004
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Side scrolling? Nov. 7th, 2012 @ 06:08 PM Reply

At 11/4/12 03:14 AM, gameObject wrote: Hi,

In the process of creating a 2d sidescroller beat 'em up.

Can anyone give me tips on how to side scroll through a level?

I would like my level to scroll in segments, meaning the level won't scroll unless all the enemies of a wave are destroyed.

fight ---> scroll ---> fight ---> scroll --->boss

Cheers

This might not be the best way to code it but It's what I'm doing for a side scroller RPG I'm making.
I put this code on an invisible boarder on the edge of the screen.

onClipEvent(enterFrame){
if (this.hitTest _root.Player && !(_root.Enemy hitTest.Screen)){
_root.Everything._x += 12;
}
}

Obviously you'll have to enter the Instance names you assigned yourself. Also make it so when the player hits the boarder they stop moving, this keeps them in the frame.
The Screen should be behind the background and fill the frame, this basicly makes it so if the character goes to the edge of the frame, the background starts scrolling instead of the player and this function stops working if you can see an enemy in frame.
I hope I helped, as I said I'm doing this in my game but that doesn't make it a good idea.


"WE HATE LOVE, WE HATE JOY, WE LOVE MONEY" - Sargent Pepper's Lonely Hearts Club Band

BBS Signature
w7y7a7t7t
w7y7a7t7t
  • Member since: Dec. 30, 2009
  • Offline.
Forum Stats
Member
Level 02
Programmer
Response to Side scrolling? Nov. 10th, 2012 @ 04:39 PM Reply

as far as i know vcam would be a terrible way to do this. first, your game is gonna take a huge performance hit. second, isn't vcam meant for animators? not for games?


If people are good only because they fear punishment, and hope for reward, then we are a sorry lot indeed.

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Online!
Forum Stats
Member
Level 10
Programmer
Response to Side scrolling? Nov. 10th, 2012 @ 05:02 PM Reply

At 11/10/12 04:39 PM, w7y7a7t7t wrote: as far as i know vcam would be a terrible way to do this. first, your game is gonna take a huge performance hit. second, isn't vcam meant for animators? not for games?

This.


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
Spudzy
Spudzy
  • Member since: Aug. 16, 2010
  • Offline.
Forum Stats
Member
Level 03
Game Developer
Response to Side scrolling? Nov. 10th, 2012 @ 06:49 PM Reply

For all of my games so far I've used a Vcam for scrolling across levels and to be honest it lags the hell out of it. You could store all of the objects apart from the player into an array and make it scroll by minusing all of their x cooridinates. I dunno just an idea.

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Member
Level 05
Game Developer
Response to Side scrolling? Nov. 10th, 2012 @ 07:18 PM Reply

At 11/10/12 06:49 PM, Spudzy wrote: For all of my games so far I've used a Vcam for scrolling across levels and to be honest it lags the hell out of it. You could store all of the objects apart from the player into an array and make it scroll by minusing all of their x cooridinates. I dunno just an idea.

or put your DisplayObjects into a DisplayObjectContainer and move the container.


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
jujaswe
jujaswe
  • Member since: May. 5, 2012
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to Side scrolling? Nov. 11th, 2012 @ 04:39 AM Reply

Put your objects inside a container and do this:

var waveCleared:Boolean = false;
if(waveCleared)
   container.x = -mcPlayer.x;

making the containers X coordinate equal to the players X coordinate will make the screen follow the player. Then if you reach the next wave, just make the waveCleared boolean to false and it will stop following the player.

CyanideHelix
CyanideHelix
  • Member since: Jun. 23, 2012
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Side scrolling? Nov. 11th, 2012 @ 04:00 PM Reply

Why not just keep the player centred and have the background scroll left to right? Unless you're doing a Streets of Rage kind of game...

MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Online!
Forum Stats
Member
Level 10
Programmer
Response to Side scrolling? Nov. 11th, 2012 @ 04:03 PM Reply

At 11/11/12 04:00 PM, CyanideHelix wrote: Why not just keep the player centred and have the background scroll left to right? Unless you're doing a Streets of Rage kind of game...

Because then you'd have to also scroll every other object in the game?


If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature
gameObject
gameObject
  • Member since: Jan. 4, 2012
  • Offline.
Forum Stats
Member
Level 03
Game Developer
Response to Side scrolling? Nov. 14th, 2012 @ 02:10 AM Reply

Thank you all for the replies.

I haven't had the chance to give your suggestions a try due to animating sprites.

feel free to keep the suggestions coming, much appreciated

gameObject
gameObject
  • Member since: Jan. 4, 2012
  • Offline.
Forum Stats
Member
Level 03
Game Developer
Response to Side scrolling? Jan. 31st, 2013 @ 04:57 AM Reply

Just wanna say thanks, I got it to work thanks to you guys.
Best of luck to all of you devs out there.