📄 wheelie.as
字号:
/**
* Paperskated3d - simple skateboard simulator in Papervision3d
*
* @author Bartek Drozdz
* @version 1.0
*
* Released under Creative Commons Attribution-Non-Commercial-Share Alike 3.0 License.
*/
package com.paperskate3d.tricks {
import com.everydayflash.util.Rotator;
import flash.geom.Point;
import caurina.transitions.Tweener;
import com.carlcalderon.arthropod.Debug;
public class Wheelie extends BasicTrick {
public var nose:Boolean;
private var rot:Rotator;
private var wheelieLevel:Number;
public var wheelieBasePosition:Array;
public function Wheelie(nose:Boolean=false) {
this.nose = nose;
if(!nose) wheelieBasePosition = [21.8, 37.7, -108];
else wheelieBasePosition = [-21.8, 37.7, -72];
}
override public function get name():String { return "wheelie" };
override protected function prepareTrick():void {
var s:Number = (nose) ? -130 : 130;
wheelieLevel = (nose) ? -18 : 18;
wheelieLevel = manager.baseRotationX - wheelieLevel;
rot = new Rotator(this, new Point(s, -50));
Tweener.addTween(rot, {
rotation:wheelieLevel,
time:TRICK_TIME * .5,
transition:"easeInOutCubic",
onComplete:balance
} );
}
public function startFromOllie(speed:Number, playbackSpeed:Number):void {
this.speed = speed;
this.playbackSpeed = playbackSpeed;
skateboard.z = 0;
skateboard.y = 0;
skateboard.rotationX = manager.baseRotationX;
var s:Number = (nose) ? -130 : 130;
wheelieLevel = (nose) ? -18 : 18;
wheelieLevel = manager.baseRotationX - wheelieLevel;
rot = new Rotator(this, new Point(s, -50));
skateboard.z = wheelieBasePosition[0];
skateboard.y = wheelieBasePosition[1];
skateboard.rotationX = wheelieBasePosition[2];
var iwl:Number = (nose) ? -6 : 6;
iwl = manager.baseRotationX - iwl;
Tweener.addTween(rot, {
rotation:iwl,
time:.3,
transition:"easeOutSine",
onComplete:balance
} );
}
private function balance():void {
var balancing:Number;
if(rotation > wheelieLevel) balancing = wheelieLevel - Math.random() * 6;
else balancing = wheelieLevel + Math.random() * 6;
Tweener.addTween(rot, {
rotation:balancing,
time: .7,
transition:"easeNone",
onComplete:balance
} );
}
public function get rotation():Number {
return skateboard.rotationX;
}
public function set rotation(r:Number):void {
skateboard.rotationX = r;
}
public function get x():Number {
return skateboard.z;
}
public function set x(nx:Number):void {
skateboard.z = nx;
}
public function get y():Number {
return skateboard.y;
}
public function set y(ny:Number):void {
skateboard.y = ny;
}
public function abort(slow:Boolean = false):void {
var ttl:Number = (slow) ? TRICK_TIME * .6 : TRICK_TIME * .2;
Tweener.addTween(rot, {
rotation:manager.baseRotationX,
time:ttl,
transition:"easeInOutCubic"
} );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -