Sign in to follow this  
Appolos

Phaser Tween positions

Recommended Posts

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.