|
obj.prototype.onEnterFrame = function() {
if( this.drag_sw == 1 ){//ドラッグ中
this.xSub = (_root._xmouse - this._x)/2
this.ySub = (_root._ymouse - this._y)/2
this._x += this.xSub
this._y += this.ySub
}else{//ドラッグしていないとき
//落下設定
this.ySpeed += this.ySpeedAdd;//加速
this._y += this.ySpeed;
this._x += this.xSpeed;
}
//着地判定
if (this._y+(this._height/2)>100) {
//地面に当たったら
this._y -= (this._y+(this._height/2))-100;
//地面を軸に座標を反転
if (this.ySpeed>0.05) {
//バウンドの力で判断
this.ySpeed *= -this.bound;
this.xSpeed *= this.bound;
} else {
//バウンドが弱まったら
delete this.onEnterFrame;//処理をとめる
}
}
//壁判定
if (this._x-(this._width/2)<0 ){
//左の壁を軸に座標を反転
this._x -= (this._x-(this._width/2)) - 0;
this.xSpeed *= -(1-this.bound);
this.ySpeed *= 1-this.bound;
}
if (this._x+(this._width/2)>100 ){
//右の壁を軸に座標を反転
this._x -= (this._x+(this._width/2)) -100;
this.xSpeed *= -(1-this.bound);
this.ySpeed *= 1-this.bound;
}
};
Object.registerClass("objects", obj);
|