flashmxboy
July 20th, 2009, 05:35 PM
Hi again
I ran into some problems while splitting my big level into tiles.
I use 10 bitmapData`s to split my level in 10 pieces and clipRect to draw only what i want to.
So i use this code:
var tile1:BitmapData = new BitmapData(grounder.width / 10,grounder.height,true,0x00FFFFFF);
var tile2:BitmapData = new BitmapData(grounder.width / 10,grounder.height,true,0x00FFFFFF);
//etc for the rest of the tiles
//Then some clipRects:
var tile1Rect:Rectangle = new Rectangle(ground.x, ground.y, ground.width/10,ground.height);
var tile2Rect:Rectangle = new Rectangle(tile1Rect.x + tile1Rect.width, tile1Rect.y, ground.width/10, ground.height);
//Etc for the rest of the tiles
//Then i draw out the first tile:
tile1.draw(ground, null,null,null,tile1Rect);
So far the code works fine:
http://nettvei.com/correctDraw.JPG
but when i use this code to draw the next tile:
tile2.draw(ground,null,null,null,tile2Rect,true);
//I set a red square to indicate where the tile rectangle is
redSquare.x = tile2Rect.x;
redSquare.y = tile2Rect.y;
redSquare.width = tile2Rect.width;
redSquare.height = tile2Rect.height;
Then this happens:
http://www.nettvei.com/wrongDraw.JPG
Pretty strange huh?
This is the ground moveiclip im drawing:
http://nettvei.com/actualDraw.JPG
Se any differences?:P
Anyway..what am i doing wrong?
Thanks in advance
I ran into some problems while splitting my big level into tiles.
I use 10 bitmapData`s to split my level in 10 pieces and clipRect to draw only what i want to.
So i use this code:
var tile1:BitmapData = new BitmapData(grounder.width / 10,grounder.height,true,0x00FFFFFF);
var tile2:BitmapData = new BitmapData(grounder.width / 10,grounder.height,true,0x00FFFFFF);
//etc for the rest of the tiles
//Then some clipRects:
var tile1Rect:Rectangle = new Rectangle(ground.x, ground.y, ground.width/10,ground.height);
var tile2Rect:Rectangle = new Rectangle(tile1Rect.x + tile1Rect.width, tile1Rect.y, ground.width/10, ground.height);
//Etc for the rest of the tiles
//Then i draw out the first tile:
tile1.draw(ground, null,null,null,tile1Rect);
So far the code works fine:
http://nettvei.com/correctDraw.JPG
but when i use this code to draw the next tile:
tile2.draw(ground,null,null,null,tile2Rect,true);
//I set a red square to indicate where the tile rectangle is
redSquare.x = tile2Rect.x;
redSquare.y = tile2Rect.y;
redSquare.width = tile2Rect.width;
redSquare.height = tile2Rect.height;
Then this happens:
http://www.nettvei.com/wrongDraw.JPG
Pretty strange huh?
This is the ground moveiclip im drawing:
http://nettvei.com/actualDraw.JPG
Se any differences?:P
Anyway..what am i doing wrong?
Thanks in advance