總之,我使用以下圓形的影片剪輯作爲圖形類的drawTriangles方法的頂點參數(矢量。)。並在第二張照片上使用該方法。AS3:graphics.drawTriangle方法奇怪的行爲
現在的事情是第一次6點工作正常,但在那之後所有的連續點不作任何區別。
還好這裏是代碼。米跳圓圈形,影片剪輯,拖拽和移動部分
//cape is instance name of movieclip
//cape width and height
var cWidth:Number = cape.width;
var cHeight:Number = cape.height;
var verteces:Vector.<Number> = new Vector.<Number>();
var indeces:Vector.<int> = new Vector.<int>();
var uvtData:Vector.<Number> = new Vector.<Number>();
//populating parameters of draw triangels
var point:Point = new Point();
for(var i:int = 1; i<=capeSkel.numChildren; i++)
{
point.x = capeSkel["pt"+i].x;
point.y = capeSkel["pt"+i].y;
verteces.push(point.x,point.y);
uvtData.push(point.x/cWidth,point.y/cHeight,1);
}
indeces.push(0,10,5, 0,1,10, 1,2,10, 2,10,7, 5,6,10, 6,7,10, 2,11,7, 2,3,11, 3,4,11,
4,11,9, 7,8,11, 8,9,11);
var capeBmd:BitmapData = new BitmapData(cWidth, cHeight, true);
capeBmd.draw(cape);
var sprite:Sprite = new Sprite();
addChild(sprite);
sprite.x = 0;
sprite.y = 260;
//this function is called everytime those movieclips are repositioned
function updateVerteces()
{
var tempVerteces:Vector.<Number> = new Vector.<Number>();
var point:Point = new Point();
//capeSkel is the instance name of circle-shaped moveiclip's parent
for(var i:int = 1; i<=capeSkel.numChildren; i++)
{
point.x = capeSkel["pt"+i].x;
point.y = capeSkel["pt"+i].y;
tempVerteces.push(point.x,point.y);
}
for(var k:int = 0; k<capeSkel.numChildren; k++)
{
verteces[k] = tempVerteces[k];
}
}
function renderView()
{
sprite.graphics.clear();
sprite.graphics.beginBitmapFill(capeBmd);
sprite.graphics.drawTriangles(verteces,indeces,uvtData);
sprite.graphics.endFill();
}
如果給出的答案爲你工作,那麼你必須勾選它是正確的,讓其他人知道它的工作原理。也不是說通過投票/嘀嗒表示「感謝」可能會導致沒有人會爲未來的問題提供幫助。他爲你做了很好的努力。 – 2014-10-18 21:03:45