开发者

AS3 - Tile image/movieclip along a line

If possible I would like to tile an image or MovieClip along a line using the standard moveTo() and lineTo() methods, The lines are directional so need to show something similar to >>>>>>>>>>>>>. The lines can be at any angle, so using drawRect() w开发者_JAVA百科ith beginBitmapFill() isn't an option. Also if possible I would like to have the lines animated.

Is this possible or will it require a custom class?


Yes, It is possible. I am assuming that by lines you mean rectangles (of certain width and are placed at certain angle let say theta.) So one way is, don't use drawRect, instead of this use moveTo and lineTo to make angled rectangles.


var matrix:Matrix = new Matrix();
matrix.rotate(theta);
graphics.beginBitmapFill(bitmapData, matrix);
graphics.moveTo(x0, y0);
graphics.lineTo(x0 + w * Math.cos(theta), y0 + w * Math.sin(theta));
graphics.lineTo(x0 + w * Math.cos(theta) - h * Math.sin(theta), y0 + w * Math.sin(theta) + h * Math.cos(theta));
graphics.lineTo(x0 - h * Math.sin(theta), y0 + h * Math.cos(theta));
graphics.endFill();
You can add as many rectangles as you want.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜