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.
精彩评论