From 4b01d770b168b9315dd73076b0914f0cdc1f1872 Mon Sep 17 00:00:00 2001 From: Raymond Hulha Date: Fri, 22 Nov 2013 15:01:38 +0100 Subject: [PATCH] added zombie spawner --- js/loadScene.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/loadScene.js b/js/loadScene.js index ce94d2b..9a4a3a6 100644 --- a/js/loadScene.js +++ b/js/loadScene.js @@ -98,6 +98,24 @@ require([ .then(null, function(e){ alert (e); }); + + window.spawnZombie = function () { + var loader_ = new DynamicLoader({world: goo.world, rootPath: 'res'}); + loader_.loadFromBundle('project.project', 'zombie.bundle').then( function() { + var z2 = loader_.getCachedObjectForRef("zombie_idle/entities/Zombie_Geo_0.entity"); + z2.transformComponent.setTranslation(0,0,0); + z2.transformComponent.setUpdated(); + z2.setComponent(new AIComponent(z2)); + z2.aIComponent.addBehavior({name:"Zombie-Idle", update:ZombieIdle}, 0); + z2.aIComponent.addBehavior({name:"Zombie-PathFind", update:ZombiePathFind}, 1); + }); + } + + document.addEventListener('keypress', function(e){ + if( e.keyCode == 114) { // r + spawnZombie(); + } + }, false); function initGoobers(goo){ console.log(loader._configs);