View Full Version : [AS2] Scrolling gameworld
03-18-2007, 12:48 PM
Hey, I'm just getting into making games in flash. I want to make a game in which you walk around a large area filled with walls, items, and enemies. All the tutorials I've seen so far have everything BUT the player move. Do any games have the player move and the view move with him? How is this done? Also, do people generally make one image be all the walls int he level, or is tiling with a bunch of objects more common? Thanks.
03-18-2007, 04:36 PM
hey and welcome to the site. A member just posted a similar question and I made a little demo file for him. I don't know if it helped him cause the ingrate....errr, I mean upstanding member never wrote back. Anyway, check this out:
if you scroll to the left and hit the very edge you will see the background starts to move. It was only a demo so I didn't program the functionality for the top, right and bottom. Also, if you notice, when you move in any direction the character knows and thus can react. If you are interested I can give you the source files and explain it to you.
03-18-2007, 04:49 PM
Yeah, this is what I'm talking about. Looking at the source would be really helpful, thanks. I just realized that maybe all 2d games have everything but the player move after he gets to the edge of the view, since the "view" doesn't really exist.. Sorry, I was raised on gamemaker!
Also, what's a good fps/screen size for playing the game through a browser? I have mine as a 640x480 at 60fps which runs great offline, but through firefox it's kinda sluggish. http://messhof.com/boolflash.html
Maybe it's also because the walls are one image? (drawn in flash, not bitmap)
03-18-2007, 06:58 PM
Sure, it is now attached. And, yeah, maybe try and make the background a bitmap. I think it will add to the preload time but it will lower the CPU procesing. The way I understand it is that Flash re-draws a vector everytime it moves. Conversly (< typo for sure) it caches a bitmap and then can move it around without having to do the math to redraw it. I could be wrong though, so I would try a bitmap and see if it increases performance.
As for my example, I make the character move and in his move function I put a conditional that says "if character's x is a the very left then stop him from moving and make the background move"
Basically that is it. You will have to add this functionality for up down and right and also add functionality that says if map is at the end ( you cannot have a background that is infinate) then dont move it anymore.
03-18-2007, 07:03 PM
or change the cacheAsBitmap property to true.
04-29-2007, 01:01 PM
I'm having trouble with the cacheAsBitmap. How do I implement this?
12-05-2009, 03:07 PM
I think your looking for the same I am where its more Super Mario World where the level moves when the character reaches a certain point.
vBulletin® v3.8.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.