var TestScene = tine._scene({ initialize: function() { var w = game.canvas.width; var h = game.canvas.height; var wh = game.canvas.width/2; var hh = game.canvas.height/2; this.regX = -wh; this.regY = -hh; this.addLayer('background'); this.addLayer('planetbg'); this.addLayer('objectsbg'); this.addLayer('objects'); this.addLayer('objectsfg'); this.addLayer('planetfg'); this.addLayer('gameinfo'); this.addLayer('ui'); this.getLayer('ui').regX = wh; this.getLayer('ui').regY = hh; this.canplay = false; this.player = { resources:game.storage.get('player.resources')||1000, } this.cursor = new Cursor(this); this.planet = new Planet(this, 150, 100); this.playerStructures = []; this.playerCreatures = []; this.enemyStructures = []; this.enemyCreatures = []; this.structures = []; this.creatures = []; this.distanceCache = []; // INITIAL CREATURES for (var i=0; i<10; i++) { var c = this.addCreature('bug', Math.random()*360); c.goTo(Math.random()*360); } // for (var i=0; i<100; i++) { // this.addCreature('marine', Math.random()*360); // } // BACKGROUND var sky = game.create.shape({regX:-wh, regY:-hh}); sky.graphics .rf(["#1D3A58", "#000"], [0, 1], 0, 0, 0, 0, 0, Math.max(w, h)) .r(-wh, -hh, w, h) this.addObject(sky, 'background'); // PLANET this.addObject(this.planet.background, 'planetbg'); this.addObject(this.planet.foreground, 'planetfg'); // CURSOR this.addObject(this.cursor.display, 'background'); // EMITTERS var shape = game.create.shape(); shape.graphics.f('red').r(-2, -2, 4, 4); this.creatureKillEmitter = new tine.Emitter(shape, 100); this.creatureKillEmitter.burstAmount = 20; this.creatureKillEmitter.angle = 0; this.creatureKillEmitter.angleVar = 140; this.creatureKillEmitter.dirXVar = 0.3; this.creatureKillEmitter.dirYVar = 0.3; this.creatureKillEmitter.speed = 25; this.creatureKillEmitter.life = 0.5; this.creatureKillEmitter.lifeVar = 0.2; this.creatureKillEmitter.endAlpha = 0; // this.creatureKillEmitter.emissionRate = 20; this.addObject(this.creatureKillEmitter, 'objectsfg'); var shape = game.create.shape(); shape.graphics.f('white').r(-5, -5, 10, 10); this.structureKillEmitter = new tine.Emitter(shape, 500); this.structureKillEmitter.burstAmount = 100; this.structureKillEmitter.angle = 0; this.structureKillEmitter.angleVar = 140; this.structureKillEmitter.dirXVar = 0.8; this.structureKillEmitter.dirYVar = 0.8; this.structureKillEmitter.speed = 50; this.structureKillEmitter.life = 0.5; this.structureKillEmitter.lifeVar = 0.2; // this.creatureKillEmitter.emissionRate = 100; this.structureKillEmitter.endAlpha = 0; this.addObject(this.structureKillEmitter, 'objectsfg'); // UI this.txtResources = game.create.text('Resources: 0', { font:'24px nasa', color:'#336482', textAlign:'left', x: 20, y: 20 }) this.addObject(this.txtResources, 'ui'); }, enter: function() { this.canplay = false; var timeout = 1; // this.structureKillEmitter.start(); // Resources label effect var r = this.player.resources; this.player.resources = 0; createjs.Tween.get(this.player).to({resources:r}, timeout, createjs.Ease.linear); // Cursor effect this.cursor.display.alpha = 0; createjs.Tween.get(this.cursor.display).to({alpha:1}, timeout); var self = this; setTimeout(function() { self.canplay=true; }, timeout); }, update: function() { this.creatureKillEmitter.update(game.time.fdelta); this.structureKillEmitter.update(game.time.fdelta); if (this.paused) return; if (this.canplay) { if (game.control.left()) { this.cursor.move(-1); } if (game.control.right()) { this.cursor.move(1); } if (game.control.action()) { this.addStructure(); } } for (var i=0; i