Hello All!
I have made a very simple turn-based game that will need to be put on a website based on AngularJS.
I am trying to get some values out of my current scene, but can’t seem to access the scene, as all functions I tried: scene.getAt(index), scene.getScene(key), as well as accessing the array directly scene.scenes[index] return either a null or undefined value.
My Angular JS directive looks like the snippet below, and prints out a full SceneManager object into the console.
app.directive('phaserGame', function() {
return {
restrict: 'E',
scope: false,
replace: true,
transclude: false,
controller: function($scope) {
// This is the config object
// 'parent' property defines the div id into which the game is to be injected
$scope.config = {
width: 800,
height: 450,
backgroundColor: '#36A9E1',
scene: [MainScene, ArenaScene],
parent: 'gameDiv'
}
// This is the most important line
// This object creates the canvas and runs the game.
$scope.game = new Phaser.Game($scope.config);
//console.log($scope.game.scene);
var arenaScene = $scope.game.scene;
console.log(arenaScene)
}
}
});
Please note, that if I change the second last line to: var arenaScene = $scope.game.scene.getAt(1) it returns an undefined value, similar to as mentioned before.
Here is the object printed out by the $scope.game.scene call: https://imgur.com/a/B9ONp0N