A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [F8] BitmapData - Infinite Scroller Questions

  1. #1
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976

    [F8] BitmapData - Infinite Scroller Questions

    Hey peeps, yesterday i told myself to learn about this BitmapData class that i have been hearing so much about lately. Now to my suprise it wasn't as complex as i thought it was going to be.

    Now what i am trying to do is create an infinite platform scroller. Made up of random tiles. But thats the problem.

    What i have done, is made a tileset.gif which is 4 tiles wide and 3 tiles high. Each tile is 70 wide and 100 high. I have 3 bitmap data objects

    tileBmp (The main tileSheet gets loaded into here)
    levelBmp (Random tiles are selected to make up a level of 40 tiles)
    screenBmp (This is the Bitmap that gets rendered to the screen

    Here is an example here of what i have done so far. (PS i just quicly made the tiles so no laughing)

    BitmapData Platform Scroller

    Now i cant seem to figure out a way to keep looping through the image to make it look like an infinite scroll. Does anyone have any concepts they have used to achieve this. Also is their a better way to do this. I was also trying to think of a way to loop through all the tiles in order an infinite amount of times. With no success.

    This is for my current project, i posted in my blog, link in my footer

    PS: Its amazing what a performance hit it takes in a browser. I get 120 fps in the flash player and max 62 fps in a browser.

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223

  3. #3
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks tonypa, i had a look at it and it seems i have done it in a very similar way to you. But for what i want to do i cant have a prerender map, it would be too short at the speed i want to scroll it would be over in a very short time. So im hoping to instead of rendering the whole map into a bitmap object, like you have done and myself. Continually render a new tile onto the end of the screen. Sort of how a tile scroller works with movie clips.

    If you still dont understand ill try to draw something up. For some reason its really hard to describe when it shouldnt be :S

    Another question. Lets say that i used copyPixel to copy a single tile to its own movieclip and scrolled that exactly like a tileBased engine. And then used scrollRect to mask the area. Would it run better then a traditional movieclip scroller? Just wondering. I would test but thought someone might have a answer to it.

    Sorry about all the weird questions. Just trying to clear a couple things up.

    Thanks again tonypa

  4. #4
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Sorry, I dont see problem with infinite scroller, you just keep making new columns into rights side and when the stage scrolls left column will disappear. If you dont want to have random stage you can use map data exactly same way like pre-bitmap scroller.

    The main improvements using bitmapdata for scrolling to me are:
    *you can use tileset images, even load them from external files
    *you scroll 1 big bitmap instead of many movie clips

  5. #5
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks tonypa. To see what i mean by your scroller not being an infinite scroller get rid of the this in your fla file.

    Code:
    if (xmove < -200) {
    		xspeed = 1;
    	} else if (xmove > 0) {
    		xspeed = -1;
    	}
    i want the impression of a never ending map. Not a fixed size map. I think i may have worked something out. That probably just apply to my game but ill post an example later today.

    Sorry about the hassle tonypa. I just cant really describe the effect im after properly.

    Thanks again mate

  6. #6
    Heli Attack! iopred's Avatar
    Join Date
    Jun 2003
    Location
    Sydney, Australia
    Posts
    923
    This is really easy to implement, when you plot a tile, just specify the array lookup something like:

    map[y%mapHeight][x%mapWidth]

    Then you can just use it like a regular scroller, except things are just plotted repeatedly from the same data. Just make sure your scroller actually does something other than creating a huge bitmap, don't like that method.
    Christopher Rhodes
    squarecircleco.

  7. #7
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Yeah thanks pred i actually just got my effect to work, here is an example. Not sure if its that fast though. Want to play with different concepts. Because i need as much speed as i can get and a decent fps.

    Here is a link to it

    Infinite Bitmap scroller

    If you hold down the RIGHT arrow key it will go on for ever. I get about 63 average fps in a browser but for some reason it still looks choppy.

    Ow and yeah like you said, it was very easy to implement. Couldnt believe it took me so long to work it out.

    Thanks again mate. And you to Tonypa

  8. #8
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thats weird, i just tested it in IE and firefox, and in IE i get 63 avg fps and in firefox it was running at 120 fps? why such a difference?

    EDIT: Ok even weirder, i just tried it again in firefox and it runs at 65 fps ? I really dont get what i did.
    Last edited by hooligan2001; 06-30-2006 at 07:40 AM.

  9. #9
    Senior Member UnknownGuy's Avatar
    Join Date
    Jul 2003
    Location
    Canada
    Posts
    1,361
    Yeah hooligan, I get similar results.

    Firefox= 120 Steady
    IE =65ish

    Weird.

  10. #10
    Senior Member Gloo pot's Avatar
    Join Date
    Aug 2005
    Location
    Australia Mate!
    Posts
    874
    I tested it in FF and got 120 all the time..
    92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!

  11. #11
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Yeah its very weird the differences im getting, something else thats weird is that when i run it in IE it starts at about 65fps and if i hold down scroll an then move my mouse off the swf and on to another area of the html page and shake my mouse cursor around i get about 110 - 120 fps. I dont understand why this happens. Is it because bitmap data can take up a large portion on ram? And is anyone else experiencing this. Or is it just me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center