2007/6/21

反彈練習

/*
onClipEvent (load) {
var max_move_x:Number = 1;
var max_move_y:Number = 1;
var dx:Number = 0;
var dy:Number = 0;
var dirx:Number = 1;
var diry:Number = 1;
var lastx = _x;
var lasty = _y;
var press_ch:Number=0;
var gg:Number=10;
setInterval(this, "setlast", 500);
function setlast():Void {
this.lastx = _x;
this.lasty = _y;


}
}
onClipEvent (enterFrame) {
//動力
_x += (this.dx*dirx);
_y += (this.dy*diry);


//阻力
this.dx = (this.dx>0) ? (this.dx-0.1) : 0;
this.dy = (this.dy>0) ? (this.dy-0.1) : 0;

//trace(bounds.xMin+","+bounds.yMin+","+bounds.xMax+","+bounds.yMax);
//改變方向
var bounds:Object = this.getBounds(_root);
if ((bounds.xMin<0>550 &&amp;amp;amp; this.dirx>0)) {
this.dirx *= -1;
}
if ((bounds.yMin<0>400 &&amp;amp;amp; this.diry>0)) {
this.diry *= -1;
}

}
on (press) {
this.dx = 0;
this.dy = 0;
this.startDrag();
this.press_ch=1;
}
on (release, releaseOutside) {
this.press_ch=0;
this.stopDrag();
if (_x>this.lastx) {
this.dirx = 1;
this.dx = this.max_move_x*(_x-this.lastx)*0.2;
} else if (_xthis.lasty) {
this.diry = 1;
this.dy = this.max_move_y*(_y-this.lasty)*0.2;
} else if (_y
this.diry = -1;
this.dy = this.max_move_y*(this.lasty-_y)*0.2;
}
}

*/

沒有留言: