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*/
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.
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 !! :-)