從我的主類我稱之爲創建一個精靈,並把它添加到舞臺ActionScript中精靈的應用旋轉的startDrag()的矩形範圍
private function addSwatch(evt:MouseEvent):void
{
if (stage.getObjectsUnderPoint(mousePoint()).length == 0)
{
var swatchSide:Number = 100;
var newSwatch:Sprite = new Swatch(0 - swatchSide/2, 0 - swatchSide/2, swatchSide, swatchSide);
newSwatch.x = mouseX;
newSwatch.y = mouseY;
addChild(newSwatch);
}
}
我添加了一個樣本精靈到哪個階段當被拖動時,被包含在設定的邊界內。
this.startDrag(false, swatchBounds());
...
private function swatchBounds():Rectangle
{
var stageBounds = new Rectangle (
0 - defaultSwatchRect.x,
0 - defaultSwatchRect.y,
stage.stageWidth - defaultSwatchRect.width,
stage.stageHeight - defaultSwatchRect.height
);
return stageBounds;
}
如果正方形Sprite進行縮放,下面返回的矩形邊界工作
private function swatchBounds():Rectangle
{
var stageBounds = new Rectangle (
0 - defaultSwatchRect.x * swatchObject.scaleX,
0 - defaultSwatchRect.y * swatchObject.scaleY,
stage.stageWidth - defaultSwatchRect.width * swatchObject.scaleX,
stage.stageHeight - defaultSwatchRect.height * swatchObject.scaleY
);
return stageBounds;
}
現在我想包括方形精靈輪換進入組合。數學當然不是我的重點,但我覺得我在寫作軌道上。不過,我只是似乎無法總結我的頭周圍做正確
private function swatchBounds():Rectangle
{
var stageBounds = new Rectangle (
0 - defaultSwatchRect.x * swatchObject.scaleX * Math.cos(defaultSwatchRect.x * swatchObject.rotation),
0 - defaultSwatchRect.y * swatchObject.scaleY * Math.sin(defaultSwatchRect.y * swatchObject.rotation),
stage.stageWidth - defaultSwatchRect.width * swatchObject.scaleX * Math.cos(defaultSwatchRect.width * swatchObject.rotation),
stage.stageHeight - defaultSwatchRect.height * swatchObject.scaleY * Math.sin(defaultSwatchRect.height * swatchObject.rotation)
);
return stageBounds;
}
這是什麼defaultSwatchRect,它是什麼意思? – jonathanasdf 2010-04-13 03:17:16
哦,是的,這是混亂。抱歉。它與swatchObject相同(在這一點上)。 defaultSwatchRect是用於創建swatchObject的站點的傳入參數。我編輯了我的文章,所以你可以希望看到我的意思 – TheDarkIn1978 2010-04-13 03:24:17
編輯並沒有真正幫助澄清什麼defaultSwatchRect不... – jonathanasdf 2010-04-13 03:35:13