Appolos Posted September 3, 2018 Share Posted September 3, 2018 Hello ! I have to variants - Phaser 3 and Phaser 2 tween creation I try to rewrite from 3d version to 2nd versions. Here, that I created: 1)Phaser 2: let sliceCoin = this.game.add.tween(this.coin, slice) sliceCoin.to({ y: game.config.height + this.apple.height, // x destination x: { // running a function to get different x ends for each slice according to frame number getEnd: function (target, key, value) { return Phaser.Math.Between(0, this.world.width / 2) + (this.world.width / 2 * (target.frame - 1));} } },gameOptions.throwSpeed * 6,Phaser.Easing.Linear.None,false,2000) sliceCoin.onComplete.add(function coinTweenCallback(tween) { this.state.start("Play") }, this) sliceCoin.start() And here Phaser 3: this.tweens.add({ // adding the knife to tween targets targets: [this.apple, slice], // y destination y: game.config.height + this.apple.height, // x destination x: { // running a function to get different x ends for each slice according to frame number getEnd: function(target, key, value){ return Phaser.Math.Between(0, game.config.width / 2) + (game.config.width / 2 * (target.frame.name - 1)); } }, // rotation destination, in radians angle: 45, // tween duration duration: gameOptions.throwSpeed * 6, // callback scope callbackScope: this, // function to be executed once the tween has been completed onComplete: function(tween){ // restart the game this.scene.start("PlayGame") } }); But Phaser 2 versions doesn't work. Sprite stay at static position. Link to comment Share on other sites More sharing options...
Recommended Posts