charlie_says Posted March 21, 2017 Share Posted March 21, 2017 Has anyone any experience of passing in external events to Phaser? I'm making a game, which Phaser will work very well for, but as part of the design there may need to be an external menu - this will navigate to various parts of the game. Generally the phaser examples are pretty self contained, and I think this request is slightly out of the ordinary. Could I send a phaser signal on the menu click and capture that within my game? Link to comment Share on other sites More sharing options...
Henrique Posted March 21, 2017 Share Posted March 21, 2017 In one of my games runs into an angular application. When the player reached highscore, I take a print out of the canvas and send the image to the server. However, this action was triggered by the game(phaser canvas), not by the angular app. // get angular scope this._scope = angular.element($('ion-view')).scope(); // call controller function this._scope.ShareRanking(this._game); in angular controller: $scope.ShareRanking = function(game) { $scope.rankingImage = game.canvas.toDataURL(); // bla bla bla ... Just do the same by adapting the code to, whatever it is using outside the phaser. scope: javascript.app { phaser.app } Just pick up the variable / function. outside canvas: var foo = function (param) {console.log ('done!', param)} inside: foo('yeah!'); Sorry for my shit English. I hope I have helped! = D Link to comment Share on other sites More sharing options...
samme Posted March 21, 2017 Share Posted March 21, 2017 As long as you have a reference to the game, you can call nearly anything. The DOM controls on, e.g., phaser-examples-mirror/animation/animation events work this way. Link to comment Share on other sites More sharing options...
charlie_says Posted March 22, 2017 Author Share Posted March 22, 2017 Thanks for the responses, I'll have a play later on to see what I can get working. Link to comment Share on other sites More sharing options...
Recommended Posts