View Full Version : scrolling the level?
spyboy1o1
02-19-2008, 09:23 PM
oright so um, ive got a game where my guy can walk and jump n stuff, and i wanna make a side scroller... so how do i make it that when he get to about 3/4th of the way to the right side of the level, it scrolls...
so far i got the guy working, and i got the screen 3000width... so what am i going to do now, something with xscale?
also how do i make it so you can only see 500px of the screen?
ok and then... i know how to make a walk animation, but what mut i do, click the guy_mc on root stage, then convert the guy from frame 1 stage guy to a mc and name it like walking, then go into that mc and put the walk animation in there? if thats right, how exactly would my code work? would it be
keypress junk...{
_root["walking"]gotoAndPlay(1);
}
bluemagica
02-20-2008, 08:51 AM
Ah, the classic question about camera...if you search for tutorials, then you will get a much better explanation than i can give here..
First of all, the canvas or stage in flash is the only part which you can actually see in your creation...everything else outside the stage stays hidden till they come on stage, so the stage is your camera....but it is fixed, to move stuff in the camera, you will have to move the actual stuff. So make your entire background into a single movieclip, say level1_mc, now if(player._x>(Stage.width*3/4)), that is if player is beyond 3/4 of stage, and a key, say the right key is pressed, then dont move player, but level1_mc._x-=4....so that creates the view effect.
atomic
02-20-2008, 01:32 PM
A couple of links that might help...
http://www.actionscript.org/showMovie.php?id=1094
http://www.leconcombre.com/board/flashtutorial/us/flashmaniacsquinzeus.html
antago
03-31-2008, 07:25 PM
Okay, first of all. It's TERRIBLY inefficient to move everything around the player and never the player itself.
Conceptually it makes more sense to move the player.
I achieved the same effect by putting the player inside the background movieclip. When I need to move the player, I do so. Then, in the main timeline I put an onEnterFrame function to move the background movieclip in relation to where the player has moved and its original default position.
Here is the simple code that you might use:
defaultPlayerX = _root.background.player._x;
defaultPlayerY = _root.background.player._y;
onEnterFrame = function() {
_root.background._x = 0 + defaultPlayerX - _root.background.player._x;
_root.background._y = 0 + defaultPlayerY - _root.background.player._y;
}
In this case, you may program a game relative to all the objects. Good luck!
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.