HTML and CSS Reference
In-Depth Information
// Satellite generates energy bubble
;(function(game, cjs, lib){
function Satellite(){
game.Building.call(this);
// graphics
this.addChild(new lib.Satellite());
this.cache(-50, -50, 100, 100);
// override
this.hp = 150;
}
Satellite.prototype = Object.create(game.Building.prototype);
Satellite.cost = 30;
game.Satellite = Satellite;
}).call(this, game, createjs, lib);
We have five types of buildings: satellite, satellite level 2, castle, castle level 2,
and space-junk. We show only the satellite.js implementaion here.
In the later tasks, we will assign a special logic to the satellites and castles, but
for now, these building implementaions are almost the same. The diferences
are mainly in the build cost and the graphics assets.
3. In the board.js ile, we add the logic for buildings. There is a selecion graphic and
a 2D map that stores the reference of the building. It also handles the events to add
the building:
function Board(){
// existing code
...
// Selection graphic
this.selection = new lib.Selection();
this.addChild(this.selection);
this.selection.visible = false;
// by default, we are not adding building
this.isAddingBuilding = false;
 
Search WWH ::




Custom Search