A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [Flash8] copyPixels Scroller

  1. #1
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666

    [Flash8] copyPixels Scroller

    This example does not use scrollRect:
    http://img296.imageshack.us/my.php?image=tiles24yc.swf


    The way it works:
    *there is tileset image in the library (1 gif with all tiles on it)
    *random tiles are then chosen from there and drawn on myBmp bitmapData
    *myBmp is 640x640 px
    *tiles mc is created
    *another bitmap (bm1) with exact size of stage is created
    *at each frame bm1 is update from bigger myBmp using copyPixels
    *bitmap (bm1) is drawn into tiles.bmp mc

    No mc is ever moved here, only thing that changes is bm1 which is updated using copyPixels.
    /*originally posted by tonypa, moved to its own thread by tomsamson*/

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    ok, here is the fla
    Attached Files Attached Files
    Last edited by tonypa; 09-15-2005 at 06:57 AM.

  3. #3
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    I have noticed some replies on the method of using bitmapdata to build the tile based game. Some notes on the subject:

    * this scrolling example is only for the background that doesnt change
    * if you have tiles that change, place them on separate tile mcs or create separate bitmap for those because you have to update it when something changes
    * to have usable data about tiles, you do not need to keep the data inside separate tile mc. It is better to create virtual tile object in memory and look up data from there
    * if you want to use 1 big tileset gif/png image, you can still save the data to be shown in each tile into 2D array or in the tile prototype:

    Instead of
    game.Tile0.prototype.frame=1;

    you could use
    game.Tile0.prototype.imgx=1;
    game.Tile0.prototype.imgy=2;

    Now you can use imgx/imgy to pick correct rectangle from tileset image.

    Or you can use single line
    game.Tile0.prototype.img=12;
    and convert it to imgx/imgy later when you need to get the image from tileset.

  4. #4
    Senior Member
    Join Date
    Jun 2001
    Posts
    290
    ok...so what you're saying is that we can still maintain a 2d array that would tell the buildMap() which tile is what...meaning what to display (image wise) as well as other propreties such as if that tile/image is walkable or not...or other things like that...

    where I'm getting confused is, because before, through the gotoAndStop engine, since tiles were MCs one could just simply "attach" the prototype of that tile to the propreties of any/all the different tiles MCs.....so then that MC became "intelligent" acquiring those prototype propreties.....

    here if we're not using MCs for each tile....what do we attach all those prototype propreties to??....meaning if all there is there is a bitmap to represent that tile....so now if the player is moving through the tileworld and needs to check if a tile is walkable or not or whatever.....how would you check for that...if it's not an MC anymore?.......would you always have to check/reference back the 2d array/obj to see what kind of propreties that tile has?....

    sorry I'm a bit confused on that.....if you could explain further, or make a simple example....that would be cool/appreciated !! :-)

    thanks,

    paul.

  5. #5
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    You can use tile objects:

    game.tile1_2=new Object();
    game.tile1_2.walkable=false;

    It doesnt create any visible mc, but you can still check if tile1_2 is walkable or not.

  6. #6
    Senior Member
    Join Date
    Jun 2001
    Posts
    290
    LOL....after writing that...and thinking about it some more I realized that ....thanks though anyway!!!

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