AngularMotion 组件
事件
- Rotated [Old rotation = {Number}]
- 当实体由于角速度/加速度旋转而旋转时,会触发旋转事件。
- NewRotationDirection [New direction = {-1 | 0 | 1}]
- 当实体因旋转速度而改变旋转方向时,会触发一个新的旋转方向事件。如果方向与上一帧不同,则触发一次事件。
- MotionChange [Motion property name and old value = { key: String, oldValue: Number }]
- 当一个动作属性发生改变时,会触发一个MotionChange事件。
允许旋转一个实体,通过应用角速度和加速度。所有的角运动值都以每秒的角度表示(例如,一个有10个旋转的单位,每秒旋转10度)。
属性
方法
Back to top
.arotation
一种用于访问/修改角(旋转)加速度的属性。加速度随时间的增加而增加,从而导致速度的增加。
例子
var ent = Crafty.e("2D, AngularMotion");
var arotation = ent.arotation; // retrieve the angular acceleration
ent.arotation += 1; // increase the angular acceleration
ent.arotation = 0; // reset the angular acceleration
Back to top
.drotation
一个数字反映了在最后一帧中应用的旋转变化(旧的和新的旋转的不同)。
例子
var ent = Crafty.e("2D, AngularMotion");
var drotation = ent.drotation; // the change of rotation in the last frame
Back to top
.vrotation
用于访问/修改角(旋转)速度的属性。速度是恒定的,除非加速度增加了速度。
例子
var ent = Crafty.e("2D, AngularMotion");
var vrotation = ent.vrotation; // retrieve the angular velocity
ent.vrotation += 1; // increase the angular velocity
ent.vrotation = 0; // reset the angular velocity