mirror of
https://github.com/photonstorm/phaser
synced 2024-12-24 20:13:35 +00:00
44 lines
2.2 KiB
JavaScript
44 lines
2.2 KiB
JavaScript
var __extends = this.__extends || function (d, b) {
|
|
function __() { this.constructor = d; }
|
|
__.prototype = b.prototype;
|
|
d.prototype = new __();
|
|
};
|
|
var Phaser;
|
|
(function (Phaser) {
|
|
(function (Particles) {
|
|
/// <reference path="../../_definitions.ts" />
|
|
(function (Initializers) {
|
|
var Velocity = (function (_super) {
|
|
__extends(Velocity, _super);
|
|
function Velocity(rpan, thapan, type) {
|
|
_super.call(this);
|
|
this.rPan = Particles.ParticleUtils.setSpanValue(rpan);
|
|
this.thaPan = Particles.ParticleUtils.setSpanValue(thapan);
|
|
this.type = Particles.ParticleUtils.initValue(type, 'vector');
|
|
}
|
|
Velocity.prototype.reset = function (rpan, thapan, type) {
|
|
this.rPan = Particles.ParticleUtils.setSpanValue(rpan);
|
|
this.thaPan = Particles.ParticleUtils.setSpanValue(thapan);
|
|
this.type = Particles.ParticleUtils.initValue(type, 'vector');
|
|
};
|
|
Velocity.prototype.normalizeVelocity = function (vr) {
|
|
return vr * Particles.ParticleManager.MEASURE;
|
|
};
|
|
Velocity.prototype.initialize = function (target) {
|
|
if(this.type == 'p' || this.type == 'P' || this.type == 'polar') {
|
|
var polar2d = new Particles.Polar2D(this.normalizeVelocity(this.rPan.getValue()), this.thaPan.getValue() * Math.PI / 180);
|
|
target.v.x = polar2d.getX();
|
|
target.v.y = polar2d.getY();
|
|
} else {
|
|
target.v.x = this.normalizeVelocity(this.rPan.getValue());
|
|
target.v.y = this.normalizeVelocity(this.thaPan.getValue());
|
|
}
|
|
};
|
|
return Velocity;
|
|
})(Initializers.Initialize);
|
|
Initializers.Velocity = Velocity;
|
|
})(Particles.Initializers || (Particles.Initializers = {}));
|
|
var Initializers = Particles.Initializers;
|
|
})(Phaser.Particles || (Phaser.Particles = {}));
|
|
var Particles = Phaser.Particles;
|
|
})(Phaser || (Phaser = {}));
|