mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Testing all ops as onUpdate capable
This commit is contained in:
parent
81473643d3
commit
9c52f8a651
3 changed files with 28 additions and 21 deletions
|
@ -336,8 +336,8 @@ var EmitterOp = new Class({
|
|||
{
|
||||
var value = this.propertyValue;
|
||||
|
||||
var onEmit;
|
||||
var onUpdate;
|
||||
var onEmit = this.defaultEmit;
|
||||
var onUpdate = this.defaultUpdate;
|
||||
|
||||
switch (method)
|
||||
{
|
||||
|
@ -400,10 +400,6 @@ var EmitterOp = new Class({
|
|||
onEmit = (this.has(value, 'onEmit')) ? value.onEmit : this.defaultEmit;
|
||||
onUpdate = (this.has(value, 'onUpdate')) ? value.onUpdate : this.defaultUpdate;
|
||||
break;
|
||||
|
||||
default:
|
||||
onEmit = this.defaultEmit;
|
||||
onUpdate = this.defaultUpdate;
|
||||
}
|
||||
|
||||
this.onEmit = onEmit;
|
||||
|
|
|
@ -259,7 +259,13 @@ var Particle = new Class({
|
|||
alpha: { min: 1, max: 1 },
|
||||
rotate: { min: 0, max: 0 },
|
||||
scaleX: { min: 1, max: 1 },
|
||||
scaleY: { min: 1, max: 1 }
|
||||
scaleY: { min: 1, max: 1 },
|
||||
x: { min: 0, max: 0 },
|
||||
y: { min: 0, max: 0 },
|
||||
accelerationX: { min: 0, max: 0 },
|
||||
accelerationY: { min: 0, max: 0 },
|
||||
maxVelocityX: { min: 0, max: 0 },
|
||||
maxVelocityY: { min: 0, max: 0 }
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -477,16 +483,18 @@ var Particle = new Class({
|
|||
* @param {number} step - The delta value divided by 1000.
|
||||
* @param {array} processors - Particle processors (gravity wells).
|
||||
*/
|
||||
computeVelocity: function (emitter, delta, step, processors)
|
||||
computeVelocity: function (emitter, delta, step, processors, t)
|
||||
{
|
||||
var ops = emitter.ops;
|
||||
|
||||
var vx = this.velocityX;
|
||||
var vy = this.velocityY;
|
||||
|
||||
var ax = this.accelerationX;
|
||||
var ay = this.accelerationY;
|
||||
var ax = ops.accelerationX.onUpdate(this, 'accelerationX', t, this.accelerationX);
|
||||
var ay = ops.accelerationY.onUpdate(this, 'accelerationY', t, this.accelerationY);
|
||||
|
||||
var mx = this.maxVelocityX;
|
||||
var my = this.maxVelocityY;
|
||||
var mx = ops.maxVelocityX.onUpdate(this, 'maxVelocityX', t, this.maxVelocityX);
|
||||
var my = ops.maxVelocityY.onUpdate(this, 'maxVelocityY', t, this.maxVelocityY);
|
||||
|
||||
vx += (emitter.gravityX * step);
|
||||
vy += (emitter.gravityY * step);
|
||||
|
@ -600,10 +608,13 @@ var Particle = new Class({
|
|||
|
||||
this.lifeT = t;
|
||||
|
||||
this.computeVelocity(emitter, delta, step, processors);
|
||||
this.computeVelocity(emitter, delta, step, processors, t);
|
||||
|
||||
this.x += this.velocityX * step;
|
||||
this.y += this.velocityY * step;
|
||||
this.x = ops.x.onUpdate(this, 'x', t, this.x + this.velocityX * step);
|
||||
this.y = ops.y.onUpdate(this, 'y', t, this.y + this.velocityY * step);
|
||||
|
||||
// this.x += this.velocityX * step;
|
||||
// this.y += this.velocityY * step;
|
||||
|
||||
if (emitter.bounds)
|
||||
{
|
||||
|
|
|
@ -299,12 +299,12 @@ var ParticleEmitter = new Class({
|
|||
this.particleClass = Particle;
|
||||
|
||||
this.ops = {
|
||||
x: new EmitterOp(config, 'x', 0, true),
|
||||
y: new EmitterOp(config, 'y', 0, true),
|
||||
accelerationX: new EmitterOp(config, 'accelerationX', 0, true),
|
||||
accelerationY: new EmitterOp(config, 'accelerationY', 0, true),
|
||||
maxVelocityX: new EmitterOp(config, 'maxVelocityX', 10000, true),
|
||||
maxVelocityY: new EmitterOp(config, 'maxVelocityY', 10000, true),
|
||||
x: new EmitterOp(config, 'x', 0),
|
||||
y: new EmitterOp(config, 'y', 0),
|
||||
accelerationX: new EmitterOp(config, 'accelerationX', 0),
|
||||
accelerationY: new EmitterOp(config, 'accelerationY', 0),
|
||||
maxVelocityX: new EmitterOp(config, 'maxVelocityX', 10000),
|
||||
maxVelocityY: new EmitterOp(config, 'maxVelocityY', 10000),
|
||||
speedX: new EmitterOp(config, 'speedX', 0, true),
|
||||
speedY: new EmitterOp(config, 'speedY', 0, true),
|
||||
moveToX: new EmitterOp(config, 'moveToX', null, true),
|
||||
|
|
Loading…
Add table
Reference in a new issue