Jump to content

Switching States


dthrasher90
 Share

Recommended Posts

Is there a way to  have phaser run mulitple tweens and switch states once the last one is completed?  How can I have phaser evaluate this?

var button = this.game.add.button(game.world.centerX, 500, 'button', function(){
                  alert("button pressed");

                  var tweenA = game.add.tween(wr1).to({x: '-200'  }, 2000);
                  var tweenB = game.add.tween(wr2).to({  y: '+200'  }, 2000);
                  var tweenC = game.add.tween(wr3).to({ x: '-200 '}, 2000);
                  var tweenD = game.add.tween(wr4).to({ y: '-200'}, 2000);

                  tweenA.start();
                  tweenB.start();
                  tweenC.start();
                  tweenD.start()

  tweenA.onComplete.add(updateMoves, this);
                    function updateMoves(){
                    var d20 = Math.floor((Math.random() * 20) + 1);

                    if(d20> 2){
                      console.log("ball caught by wr3");
                      game.state.add('HuddleState', HuddleState);
                      game.state.start('HuddleState');

                    } else {
                      console.log('incommplete pass');


                    }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...