I have a game that I created using three.js , which is fully displayed in the canvas element.
As an exercise to help me get to know Angular JS , I started adding a user interface layer on top of my canvas that should be managed by the Angular framework.
A rough example of my markup looks like this:
<div class="container" ng-app="hud-layer"> <div class="level" ng-controller="HUDCtrl"> <h1>Level: {{level}}</h1> <button ng-click="decreaseLevel()">-</button> <button ng-click="increaseLevel()">+</button> </div> <div id="game"></div> </div>
I obviously intend to add more user interface elements to my HUD, but I need to know how to call functions in my game. js from Angular.
My game.js is encapsulated in its own namespace, for example:
(function(){ var VECTORS = { init: function(){ }, reset: function(){ }
I want Angular to monitor the level, evaluate variables, etc., but I want these variables reflected in my game.js game, do I have to somehow reflect $ scope in game.js?
Any help or guidance appreciated.
source share