mirror of
https://github.com/wassname/phaser.git
synced 2026-08-03 13:10:25 +08:00
make tweens chain loopable
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
var p;
|
||||
var p2;
|
||||
|
||||
function preload() {
|
||||
|
||||
@@ -27,13 +26,11 @@
|
||||
game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true)
|
||||
.to({ y: 300 }, 1000, Phaser.Easing.Linear.None)
|
||||
.to({ x: 0 }, 1000, Phaser.Easing.Linear.None)
|
||||
.to({ y: 0 }, 1000, Phaser.Easing.Linear.None);
|
||||
.to({ y: 0 }, 1000, Phaser.Easing.Linear.None)
|
||||
.loop();
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// p.y = game.math.min(100, game.input.y);
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
+18
-1
@@ -76,7 +76,7 @@ Phaser.Tween.prototype = {
|
||||
if (this._parent)
|
||||
{
|
||||
self = this._manager.create(this._object);
|
||||
self._parent = this;
|
||||
self._parent = this._parent;
|
||||
this.chain(self);
|
||||
}
|
||||
else
|
||||
@@ -206,6 +206,23 @@ Phaser.Tween.prototype = {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Loop a chain of tweens
|
||||
*
|
||||
* Usage:
|
||||
* game.add.tween(p).to({ x: 700 }, 1000, Phaser.Easing.Linear.None, true)
|
||||
* .to({ y: 300 }, 1000, Phaser.Easing.Linear.None)
|
||||
* .to({ x: 0 }, 1000, Phaser.Easing.Linear.None)
|
||||
* .to({ y: 0 }, 1000, Phaser.Easing.Linear.None)
|
||||
* .loop();
|
||||
*
|
||||
* @return {Tween} Itself.
|
||||
*/
|
||||
loop: function() {
|
||||
if (this._parent) this.chain(this._parent);
|
||||
return this;
|
||||
},
|
||||
|
||||
onStartCallback: function ( callback ) {
|
||||
|
||||
this._onStartCallback = callback;
|
||||
|
||||
Reference in New Issue
Block a user