HTML and CSS Reference
In-Depth Information
Then, we export these graphics into a JS file that we can use directly in the CreateJS library.
Or, you can find the file from the code bundle.
We create another new file, view.js . We will place the logic to control the assets there.
Specifically, we control the power indicator graphics inside this file.
We will need to include the new files into the HTML before we move on:
<script src="scripts/assets.js"></script>
<script src="scripts/view.js"></script>
Engage thrusters
Let's execute the following steps to create the power indicator:
1. First, we set up a new file called view.js . Inside the ile, we iniialize the power
indicator graphics and define methods that show/hide it, rotate it, and also update
the length of the power bar:
var game = this.game || (this.game={});
var createjs = createjs || {};
;(function(game, cjs){
game.view = game.view || {};
game.view.initPowerIndicator = function() {
this.power = new lib.PowerArrow();
game.stage.addChild(this.power);
this.power.visible = false; // we hide it upon init.
};
 
Search WWH ::




Custom Search