頁:
[1]
物體彈跳 AS3 很大的問題
請問一下有人可以跟我解釋一下假若有一個元件的實體名稱叫做ball
那以下這一段語法誰可以幫我行行註解呢? 謝謝 :)
numPoints = 1;
var slice = 6.283185 / numPoints;
ball.lineStyle(1, 0, 100);
ball.rads = new Array();
var i = 0;
while (i < numPoints)
{
var radius = Math.random() * 50 + 50;
ball.rads.push(radius);
var x = Math.cos(slice * i) * radius;
var y = Math.sin(slice * i) * radius;
ball.moveTo(0, 0);
ball.lineTo(x, y);
++i;
} // end while
ball.vx = 0;
ball.vy = 0;
ball.vr = 1;
grav = 3.000000;
ball.onPress = function ()
{
this.startDrag();
this.dragging = true;
this.oldx = this._x;
this.oldy = this._y;
};
ball.onRelease = ball.onReleaseOutside = function ()
{
this.stopDrag();
this.dragging = false;
};
ball.onEnterFrame = function ()
{
if (!this.dragging)
{
this.vy = this.vy + grav;
var _loc8 = this._rotation * 3.141593 / 180;
for (var _loc2 = 0; _loc2 < numPoints; ++_loc2)
{
var _loc3 = slice * _loc2 + _loc8;
var _loc7 = this._x + this.rads * Math.cos(_loc3);
var _loc4 = this._y + this.rads * Math.sin(_loc3);
if (_loc4 > 340)
{
this._y = this._y - (_loc4 - 290);
this.vy = this.vy * -0.700000;
var _loc5 = _loc3 - 1.570796;
var _loc6 = Math.sin(_loc5) * 5;
this.vr = this.vr + _loc6;
} // end if
} // end of for
}
else
{
this.vx = this._x - this.oldx;
this.vy = this._y - this.oldy;
this.oldx = this._x;
this.oldy = this._y;
} // end else if
if (this._x < 50)
{
this._x =50;
this.vx = this.vx * -0.900000;
}
else if (this._x > 400)
{
this._x = 400;
this.vx = this.vx * -0.900000;
} // end else if
this._x = this._x + this.vx;
this._y = this._y + this.vy;
this.vr = this.vr * 0.950000;
this._rotation = this._rotation + this.vr;
};
補充內容 (2012-4-20 10:09 AM):
若要讓其兩個物體有相互碰撞的效果
在這語法的基本架構下要如何寫出碰撞效果呢?...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div>
頁:
[1]