|
-
non tile based scrolling help!
I'm making a game which will have scrolling up, down, left and right, kind of like in Zelda games. However, the maps will be rather detailed, so I can't really do tile based scrolling. I'm try to find a way to make the scrolling non tile based, but not cpu intensive at the same time.
I've found 2 ways so far, but both are pretty laggy. One way is to make the stage huge and draw the whole map on the stage, then have the char move around and have a virtual camera following the character. The other way is to have the map as a movieclip and make that move instead of the char, or have boundary boxes that shift the map.
Any help would be greatly appreciated.
I also have a questions about general lag:
Does only the frame that movieclips are on affect how much lag it has, or the whole size of the movieclip? What I mean is, say I had several cannons on a map that rotate and fire at your character. If I had all of the cannon animations on frame two and just a blank frame one, then coded the mc so that it switches to frame two when you move next to it, but stays on frame one when you are far away, if that will reduce lag.
-
Senior Member
err just create a bitmap the size of the stage then use copyPixel to draw the viewable portion of your level on it! should be efficient enough!
Actually the images themselves don't cause much noticeable lag, lag is caused by the amount of memory used (when you use a movieclip it is loaded and kept in memory), and how much cpu it is eating( this portion is mainly handled by the coding side of the game)!
If you like me, add me to your friends list  .
PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!
My Arcade My Blog
Add me on twitter: 
-
Like above,
I think your best bet is importing or embedding the largest gif of the map you can then using BitmapData.copyPixel to scroll it. Not sure of the image size limit. You could just use 2 or 4 if you need a very very large map.
-
Senior Member
Easy way to reduce lag is to reduce size of game. Scrolling 800x600 screen will surely be slower then 400x300.
-
thanks for your replies
I'm not familiar with the copypixel command, are there any tutorials about it?
I googled it but I didn't get much on how to use it.
-
the LiveDocs/F1 is your best resource for copyPixel
Basically, you will create a BitmapData of the image you want to scroll and another BitmapData which is the screen of your game. Create a new Bitmap from your screen bmd at the start and you can call addChild(thebitmap) with this. To update the Bitmap, see below. All the editing is done to the BitmapData, you don't need any more manipulation with the Bitmap after you create it.
call this before your loop, or enterframe as an optimization. This way you don't make a new rectangle/point 30 times a second that has to be allocated/garbage collected. In general, this is a good coding practice, not calling new where you don't need to. It is also much faster to just change x/y rather than making a new object with the new x/y.
Code:
var rect:Rectangle = new Rectangle(0, 0, screenWidth, screenHeight)
var p:Point = new Point() //defaults to (0, 0)
...
in your drawing function
Code:
rect.x=gameX//this is the top left corner of the screen sized rectangle you are going to copy
rect.y=gameY//^^
screen.copyPixels(BigBitmapData, rect, p)
-
Senior Member
go to 8bitrockets site, it is filled with bitmapData based examples and tutorials, and i myself learned from there!
If you like me, add me to your friends list  .
PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!
My Arcade My Blog
Add me on twitter: 
-
Do you mean mochiads.com? That's the first site that came up when I googled 8bitrockets.
-
Senior Member
If you like me, add me to your friends list  .
PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!
My Arcade My Blog
Add me on twitter: 
-
oh, lol, I tried 8bitrockets.com, but nothing came up, I didn't think of trying it without the s.
Thanks for all your responses
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|