mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Remove ES6+ syntax in tweenruntimebehavior.js for backwards compatibility (#1151)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* @param {Object} behaviorData The data to initialize the behavior
|
||||
* @param {gdjs.RuntimeObject} owner The runtime object the behavior belongs to.
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior = function(runtimeScene, behaviorData, owner) {
|
||||
gdjs.TweenRuntimeBehavior = function (runtimeScene, behaviorData, owner) {
|
||||
gdjs.RuntimeBehavior.call(this, runtimeScene, behaviorData, owner);
|
||||
|
||||
/** @type Object.<string, gdjs.TweenRuntimeBehavior.TweenInstance > */
|
||||
@@ -66,7 +66,7 @@ gdjs.TweenRuntimeBehavior.easings = [
|
||||
* @param {number} startTime The time at which the tween starts
|
||||
* @param {number} totalDuration The time of the whole tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.TweenInstance = function(
|
||||
gdjs.TweenRuntimeBehavior.TweenInstance = function (
|
||||
instance,
|
||||
hasFinished,
|
||||
startTime,
|
||||
@@ -79,7 +79,7 @@ gdjs.TweenRuntimeBehavior.TweenInstance = function(
|
||||
this.resumeOnActivate = false;
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._addTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._addTween = function (
|
||||
identifier,
|
||||
instance,
|
||||
startTime,
|
||||
@@ -93,19 +93,19 @@ gdjs.TweenRuntimeBehavior.prototype._addTween = function(
|
||||
);
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._getTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._getTween = function (identifier) {
|
||||
return this._tweens[identifier];
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenExists = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenExists = function (identifier) {
|
||||
return !!this._tweens[identifier];
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenIsPlaying = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenIsPlaying = function (identifier) {
|
||||
return this._tweens[identifier].instance.isPlaying();
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._pauseTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._pauseTween = function (identifier) {
|
||||
var tween = this._tweens[identifier];
|
||||
|
||||
// Pause the tween, and remove it from the scene of living tweens
|
||||
@@ -116,12 +116,12 @@ gdjs.TweenRuntimeBehavior.prototype._pauseTween = function(identifier) {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._resumeTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._resumeTween = function (identifier) {
|
||||
var tween = this._tweens[identifier];
|
||||
|
||||
// Resume the tween, and add it back to the scene of living tweens
|
||||
// (the invariant is that scene only contains tweens being played).
|
||||
tween.instance.resume().catch(() => {
|
||||
tween.instance.resume().catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
@@ -132,32 +132,32 @@ gdjs.TweenRuntimeBehavior.prototype._resumeTween = function(identifier) {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._stopTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._stopTween = function (
|
||||
identifier,
|
||||
jumpToDest
|
||||
) {
|
||||
return this._tweens[identifier].instance.stop(jumpToDest);
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._setTweenFinished = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._setTweenFinished = function (
|
||||
identifier,
|
||||
hasFinished
|
||||
) {
|
||||
this._tweens[identifier].hasFinished = hasFinished;
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenHasFinished = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._tweenHasFinished = function (identifier) {
|
||||
return this._tweens[identifier].hasFinished;
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._removeObjectFromScene = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._removeObjectFromScene = function (
|
||||
identifier
|
||||
) {
|
||||
this._removeTween(identifier);
|
||||
return this.owner.deleteFromScene(this._runtimeScene);
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._removeTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype._removeTween = function (identifier) {
|
||||
if (!this._tweens[identifier]) return;
|
||||
|
||||
this._tweens[identifier].instance.stop();
|
||||
@@ -168,23 +168,24 @@ gdjs.TweenRuntimeBehavior.prototype._removeTween = function(identifier) {
|
||||
delete this._tweens[identifier];
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype._setupTweenEnding = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype._setupTweenEnding = function (
|
||||
identifier,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (destroyObjectWhenFinished) {
|
||||
this._tweens[identifier].instance
|
||||
.tween()
|
||||
.catch(() => {
|
||||
.catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
// ensure that the content of the "then" is always applied:
|
||||
})
|
||||
.then(() => {
|
||||
this._removeObjectFromScene(identifier);
|
||||
.then(function () {
|
||||
that._removeObjectFromScene(identifier);
|
||||
})
|
||||
.catch(() => {
|
||||
.catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
@@ -193,18 +194,18 @@ gdjs.TweenRuntimeBehavior.prototype._setupTweenEnding = function(
|
||||
} else {
|
||||
this._tweens[identifier].instance
|
||||
.tween()
|
||||
.catch(() => {
|
||||
.catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
// ensure that the content of the "then" is always applied:
|
||||
})
|
||||
.then(() => {
|
||||
if (this._tweens[identifier]) {
|
||||
this._tweens[identifier].hasFinished = true;
|
||||
.then(function () {
|
||||
if (that._tweens[identifier]) {
|
||||
that._tweens[identifier].hasFinished = true;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch(function () {
|
||||
// Do nothing if the Promise is rejected. Rejection is used
|
||||
// by Shifty.js to signal that the tween was not finished.
|
||||
// We catch it to avoid an uncaught promise error, and to
|
||||
@@ -223,7 +224,7 @@ gdjs.TweenRuntimeBehavior.prototype._setupTweenEnding = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addVariableTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addVariableTween = function (
|
||||
identifier,
|
||||
variable,
|
||||
fromValue,
|
||||
@@ -252,7 +253,7 @@ gdjs.TweenRuntimeBehavior.prototype.addVariableTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
step: function step(state) {
|
||||
variable.setNumber(state.value);
|
||||
}
|
||||
});
|
||||
@@ -276,7 +277,7 @@ gdjs.TweenRuntimeBehavior.prototype.addVariableTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function (
|
||||
identifier,
|
||||
toX,
|
||||
toY,
|
||||
@@ -284,6 +285,7 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function(
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!!gdjs.TweenRuntimeBehavior.easings[easingValue]) return;
|
||||
|
||||
@@ -305,9 +307,9 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setX(state.x);
|
||||
this.owner.setY(state.y);
|
||||
step: function step(state) {
|
||||
that.owner.setX(state.x);
|
||||
that.owner.setY(state.y);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -329,13 +331,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionXTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionXTween = function (
|
||||
identifier,
|
||||
toX,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!!gdjs.TweenRuntimeBehavior.easings[easingValue]) return;
|
||||
|
||||
@@ -355,8 +358,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionXTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setX(state.x);
|
||||
step: function step(state) {
|
||||
that.owner.setX(state.x);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -378,13 +381,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionXTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionYTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectPositionYTween = function (
|
||||
identifier,
|
||||
toY,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!!gdjs.TweenRuntimeBehavior.easings[easingValue]) return;
|
||||
|
||||
@@ -404,8 +408,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionYTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setY(state.y);
|
||||
step: function step(state) {
|
||||
that.owner.setY(state.y);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -427,13 +431,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectPositionYTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectAngleTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectAngleTween = function (
|
||||
identifier,
|
||||
toAngle,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!!gdjs.TweenRuntimeBehavior.easings[easingValue]) return;
|
||||
|
||||
@@ -453,8 +458,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectAngleTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setAngle(state.angle);
|
||||
step: function step(state) {
|
||||
that.owner.setAngle(state.angle);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -477,7 +482,7 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectAngleTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function (
|
||||
identifier,
|
||||
toScaleX,
|
||||
toScaleY,
|
||||
@@ -485,6 +490,7 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function(
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.setScaleX || !this.owner.setScaleY) return;
|
||||
|
||||
@@ -511,9 +517,9 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setScaleX(state.scaleX);
|
||||
this.owner.setScaleY(state.scaleY);
|
||||
step: function step(state) {
|
||||
that.owner.setScaleX(state.scaleX);
|
||||
that.owner.setScaleY(state.scaleY);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -535,13 +541,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleXTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleXTween = function (
|
||||
identifier,
|
||||
toScaleX,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.setScaleX) return;
|
||||
|
||||
@@ -563,8 +570,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleXTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setScaleX(state.scaleX);
|
||||
step: function step(state) {
|
||||
that.owner.setScaleX(state.scaleX);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -586,13 +593,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleXTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleYTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectScaleYTween = function (
|
||||
identifier,
|
||||
toScaleY,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.setScaleY) return;
|
||||
|
||||
@@ -614,8 +622,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleYTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setScaleY(state.scaleY);
|
||||
step: function step(state) {
|
||||
that.owner.setScaleY(state.scaleY);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -637,13 +645,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectScaleYTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectOpacityTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectOpacityTween = function (
|
||||
identifier,
|
||||
toOpacity,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.getOpacity || !this.owner.setOpacity) return;
|
||||
|
||||
@@ -665,8 +674,8 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectOpacityTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setOpacity(state.opacity);
|
||||
step: function step(state) {
|
||||
that.owner.setOpacity(state.opacity);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -688,13 +697,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectOpacityTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectColorTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addObjectColorTween = function (
|
||||
identifier,
|
||||
toColor,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.getColor || !this.owner.setColor) return;
|
||||
if (
|
||||
@@ -730,13 +740,13 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectColorTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setColor(
|
||||
step: function step(state) {
|
||||
that.owner.setColor(
|
||||
Math.floor(state.red) +
|
||||
";" +
|
||||
Math.floor(state.green) +
|
||||
";" +
|
||||
Math.floor(state.blue)
|
||||
";" +
|
||||
Math.floor(state.green) +
|
||||
";" +
|
||||
Math.floor(state.blue)
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -759,13 +769,14 @@ gdjs.TweenRuntimeBehavior.prototype.addObjectColorTween = function(
|
||||
* @param {number} durationValue Duration in milliseconds
|
||||
* @param {boolean} destroyObjectWhenFinished Destroy this object when the tween ends
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.addTextObjectCharacterSizeTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.addTextObjectCharacterSizeTween = function (
|
||||
identifier,
|
||||
toSize,
|
||||
easingValue,
|
||||
durationValue,
|
||||
destroyObjectWhenFinished
|
||||
) {
|
||||
var that = this;
|
||||
if (!this._isActive) return;
|
||||
if (!this.owner.setCharacterSize) return;
|
||||
|
||||
@@ -787,8 +798,8 @@ gdjs.TweenRuntimeBehavior.prototype.addTextObjectCharacterSizeTween = function(
|
||||
},
|
||||
duration: durationValue,
|
||||
easing: easingValue,
|
||||
step: state => {
|
||||
this.owner.setCharacterSize(state.size);
|
||||
step: function step(state) {
|
||||
that.owner.setCharacterSize(state.size);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -806,7 +817,7 @@ gdjs.TweenRuntimeBehavior.prototype.addTextObjectCharacterSizeTween = function(
|
||||
* Tween is playing.
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.isPlaying = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.isPlaying = function (identifier) {
|
||||
if (this._tweenExists(identifier) && this._tweenIsPlaying(identifier)) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -819,7 +830,7 @@ gdjs.TweenRuntimeBehavior.prototype.isPlaying = function(identifier) {
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
* @returns {boolean} The tween exists
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.exists = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.exists = function (identifier) {
|
||||
return this._tweenExists(identifier);
|
||||
};
|
||||
|
||||
@@ -827,7 +838,7 @@ gdjs.TweenRuntimeBehavior.prototype.exists = function(identifier) {
|
||||
* Tween has finished.
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.hasFinished = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.hasFinished = function (identifier) {
|
||||
if (this._tweenExists(identifier)) {
|
||||
return this._tweenHasFinished(identifier);
|
||||
} else {
|
||||
@@ -839,7 +850,7 @@ gdjs.TweenRuntimeBehavior.prototype.hasFinished = function(identifier) {
|
||||
* Pause a tween.
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.pauseTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.pauseTween = function (identifier) {
|
||||
if (!this._isActive) return;
|
||||
|
||||
if (this._tweenExists(identifier) && this._tweenIsPlaying(identifier)) {
|
||||
@@ -852,7 +863,7 @@ gdjs.TweenRuntimeBehavior.prototype.pauseTween = function(identifier) {
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
* @param {boolean} jumpToDest Move to destination
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.stopTween = function(
|
||||
gdjs.TweenRuntimeBehavior.prototype.stopTween = function (
|
||||
identifier,
|
||||
jumpToDest
|
||||
) {
|
||||
@@ -867,7 +878,7 @@ gdjs.TweenRuntimeBehavior.prototype.stopTween = function(
|
||||
* Resume a tween.
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.resumeTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.resumeTween = function (identifier) {
|
||||
if (!this._isActive) return;
|
||||
|
||||
if (this._tweenExists(identifier) && !this._tweenIsPlaying(identifier)) {
|
||||
@@ -879,7 +890,7 @@ gdjs.TweenRuntimeBehavior.prototype.resumeTween = function(identifier) {
|
||||
* Remove a tween.
|
||||
* @param {string} identifierFirst Unique id to idenfify the tween
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.removeTween = function(identifier) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.removeTween = function (identifier) {
|
||||
this._removeTween(identifier);
|
||||
};
|
||||
|
||||
@@ -888,8 +899,8 @@ gdjs.TweenRuntimeBehavior.prototype.removeTween = function(identifier) {
|
||||
* @param {string} identifier Unique id to idenfify the tween
|
||||
* @returns {boolean} Progress of playing tween animation (between 0.0 and 1.0)
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.prototype.getProgress = function(identifier) {
|
||||
const tween = this._getTween(identifier);
|
||||
gdjs.TweenRuntimeBehavior.prototype.getProgress = function (identifier) {
|
||||
var tween = this._getTween(identifier);
|
||||
if (tween) {
|
||||
var currentTime = this._runtimeScene.getTimeManager().getTimeFromStart();
|
||||
if (currentTime >= tween.startTime + tween.totalDuration) return 1;
|
||||
@@ -900,12 +911,12 @@ gdjs.TweenRuntimeBehavior.prototype.getProgress = function(identifier) {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype.onDeActivate = function() {
|
||||
gdjs.TweenRuntimeBehavior.prototype.onDeActivate = function () {
|
||||
if (!this._isActive) return;
|
||||
|
||||
for (const key in this._tweens) {
|
||||
for (var key in this._tweens) {
|
||||
if (this._tweens.hasOwnProperty(key)) {
|
||||
const tween = this._tweens[key];
|
||||
var tween = this._tweens[key];
|
||||
|
||||
if (tween.instance.isPlaying()) {
|
||||
tween.resumeOnActivate = true;
|
||||
@@ -916,12 +927,12 @@ gdjs.TweenRuntimeBehavior.prototype.onDeActivate = function() {
|
||||
this._isActive = false;
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype.onActivate = function() {
|
||||
gdjs.TweenRuntimeBehavior.prototype.onActivate = function () {
|
||||
if (this._isActive) return;
|
||||
|
||||
for (const key in this._tweens) {
|
||||
for (var key in this._tweens) {
|
||||
if (this._tweens.hasOwnProperty(key)) {
|
||||
const tween = this._tweens[key];
|
||||
var tween = this._tweens[key];
|
||||
|
||||
if (tween.resumeOnActivate) {
|
||||
tween.resumeOnActivate = false;
|
||||
@@ -940,7 +951,7 @@ gdjs.TweenRuntimeBehavior.prototype.onActivate = function() {
|
||||
* @param {gdjs.RuntimeScene} runtimeScene
|
||||
* @returns {shifty.Tweenable} The new tweenable
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.makeNewTweenable = function(runtimeScene) {
|
||||
gdjs.TweenRuntimeBehavior.makeNewTweenable = function (runtimeScene) {
|
||||
if (!runtimeScene.shiftyJsScene) {
|
||||
runtimeScene.shiftyJsScene = new shifty.Scene();
|
||||
}
|
||||
@@ -956,7 +967,7 @@ gdjs.TweenRuntimeBehavior.makeNewTweenable = function(runtimeScene) {
|
||||
* @param {gdjs.RuntimeScene} runtimeScene
|
||||
* @param {shifty.Tweenable} tweenable
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.removeFromScene = function(runtimeScene, tweenable) {
|
||||
gdjs.TweenRuntimeBehavior.removeFromScene = function (runtimeScene, tweenable) {
|
||||
if (!runtimeScene.shiftyJsScene) return;
|
||||
|
||||
runtimeScene.shiftyJsScene.remove(tweenable);
|
||||
@@ -969,7 +980,7 @@ gdjs.TweenRuntimeBehavior.removeFromScene = function(runtimeScene, tweenable) {
|
||||
* Stop and "destroy" all the tweens when a scene is unloaded.
|
||||
* @private
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneUnloaded = function(
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneUnloaded = function (
|
||||
runtimeScene
|
||||
) {
|
||||
if (!runtimeScene.shiftyJsScene) return;
|
||||
@@ -986,7 +997,7 @@ gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneUnloaded = function(
|
||||
* When a scene is paused, pause all the tweens of this scene.
|
||||
* @private
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeScenePaused = function(
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeScenePaused = function (
|
||||
runtimeScene
|
||||
) {
|
||||
if (!runtimeScene.shiftyJsScene) return;
|
||||
@@ -998,7 +1009,7 @@ gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeScenePaused = function(
|
||||
* When a scene is paused, resume all the tweens of this scene.
|
||||
* @private
|
||||
*/
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneResumed = function(
|
||||
gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneResumed = function (
|
||||
runtimeScene
|
||||
) {
|
||||
if (!runtimeScene.shiftyJsScene) return;
|
||||
@@ -1021,7 +1032,7 @@ gdjs.TweenRuntimeBehavior.gdjsCallbackRuntimeSceneResumed = function(
|
||||
gdjs.TweenRuntimeBehavior._tweensProcessed = false;
|
||||
gdjs.TweenRuntimeBehavior._currentTweenTime = 0;
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype.doStepPreEvents = function(runtimeScene) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.doStepPreEvents = function (runtimeScene) {
|
||||
// Process tweens (once per frame).
|
||||
if (!gdjs.TweenRuntimeBehavior._tweensProcessed) {
|
||||
gdjs.TweenRuntimeBehavior._currentTweenTime = runtimeScene
|
||||
@@ -1032,19 +1043,19 @@ gdjs.TweenRuntimeBehavior.prototype.doStepPreEvents = function(runtimeScene) {
|
||||
}
|
||||
};
|
||||
|
||||
gdjs.TweenRuntimeBehavior.prototype.doStepPostEvents = function(runtimeScene) {
|
||||
gdjs.TweenRuntimeBehavior.prototype.doStepPostEvents = function (runtimeScene) {
|
||||
gdjs.TweenRuntimeBehavior._tweensProcessed = false;
|
||||
};
|
||||
|
||||
// Set up Shifty.js so that the processing ("tick"/updates) is handled
|
||||
// by the behavior (once per frame):
|
||||
shifty.Tweenable.setScheduleFunction(function() {
|
||||
shifty.Tweenable.setScheduleFunction(function () {
|
||||
/* Do nothing, we'll call processTweens manually. */
|
||||
});
|
||||
|
||||
// Set up Shifty.js so that the time is handled by the behavior.
|
||||
// It will be set to be the time of the current scene, and should be updated
|
||||
// before any tween processing (processTweens, resume).
|
||||
shifty.Tweenable.now = function() {
|
||||
shifty.Tweenable.now = function () {
|
||||
return gdjs.TweenRuntimeBehavior._currentTweenTime;
|
||||
};
|
||||
|
Reference in New Issue
Block a user