1

I have array of tiles and they are drawn on my "canvas".

I know how to transform my canvas to scale from it's center:

var m:Matrix = new Matrix();
m.translate(-centerX, -centerY);
m.scale(scaleX, scaleY);
m.translate(centerX, centerY);

This will scale and translate tile to its x,y

var m:Matrix = new Matrix();
m.translate(_tile.x,_tile.y);
m.scale(_scale, _scale);

But how do I scale all my bitmap tiles from center while I'm drawing them on "canvas"

4

1 回答 1

0

此代码显示如何使用 BitmapData.draw 方法缩放和居中平铺位图数据(tile_1 是“(0,0)”排列的位图):

var tile:BitmapData = new tile_1();
var canvas:BitmapData = new BitmapData(1000, 1000, true, 0x00FFFFFF);
var scale:Number = 2;
canvas.draw(tile, new Matrix(scale, 0, 0, scale, -tile.width*scale/2, -tile.height*scale/2));

如果您使用其他技术绘制瓷砖,请更详细地描述它。

于 2013-01-04T14:58:35.510 回答