m4rk2s Posted October 26, 2016 Share Posted October 26, 2016 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 More sharing options...
squilibob Posted October 26, 2016 Share Posted October 26, 2016 You can add multiple listeners to the same object // Mouse click events this.game.input.onDown.add(this.translate, this); this.game.input.onDown.add(this.roatate, this); Link to comment Share on other sites More sharing options...
m4rk2s Posted October 26, 2016 Author Share Posted October 26, 2016 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. Link to comment Share on other sites More sharing options...
m4rk2s Posted October 26, 2016 Author Share Posted October 26, 2016 this is what i want to do : just rotating the 14 domino and when it's okey it does something Sardar 1 Link to comment Share on other sites More sharing options...
squilibob Posted October 26, 2016 Share Posted October 26, 2016 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 More sharing options...
m4rk2s Posted October 26, 2016 Author Share Posted October 26, 2016 oh well done ! thank you Link to comment Share on other sites More sharing options...
Recommended Posts