Jump to content

How to mange two functions with click


m4rk2s
 Share

Recommended Posts

Hi !

here is my problem : I want to manage two tweens with only one click

the images are here https://github.com/aneurycasado/Dominos-Para-Los-Dominicanos-No-Server/tree/master/images/Dominos

var a, b
playState = {
    init: function(){
      game.device.desktop,
      game.scale.pageAlignHorizontally = !0,
      game.scale.pageAlignVertically = !0,
      document.body.style.backgroundColor = "#CCCCCC",
      game.stage.backgroundColor = "#CCCCCC",
      game.physics.startSystem(Phaser.Physics.ARCADE)
    },

    preload: function() {
        game.load.image("44", "assets/[4,4].png")
        game.load.image("14", "assets/[1,4].png")
    },

    create: function() {
      this.init()
      game.world.setBounds(0, 0, 800, 600);

      a = game.add.image(200, 100, "44");
      a.scale.setTo(0.3)
      a.anchor.set(.5, .5);

      b = game.add.image(200, 100, "14");
      b.scale.setTo(0.3)
      b.anchor.set(.5, .5);

      // Mouse click events
		  this.game.input.onDown.add(this.translate, this);
    },

    translate: function(pointer){
      var c = game.add.tween(a).to({x: 400, y: 300, angle: 0, alpha: 1}, 1000, "Quad.easeInOut", true, 1000);
    },

    roatate: function(pointer){
      var c = game.add.tween(b).to({angle: 45}, 2000, Phaser.Easing.Linear.None, true)
    }
},

game = new Phaser.Game(800, 600);
game.state.add("play", playState),
game.state.start("play");

 

Link to comment
Share on other sites

26 minutes ago, m4rk2s said:

thank you @squilbob it seems that i get this error

Error: Phaser.Signal: listener is a required param of add() and should be a Function.

You are spelling something wrong. I noticed that you are using roatate instead of rotate? I downloaded your images and ran your code, it works.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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