keyboard.onKeyDown(keyboard.A, this, function() { reclaimer.claimAll(); gb.add('Base_1', 'First', 'MainFront'); gb.add('Base_2', 'First', 'MainMiddle'); gb.add('Base_3', 'First', 'MainBack'); });
game.on(game.CREATE, this, function() { console.log("Welcome to Game-Builder!"); require('layering-bundle').create(); gb.add('Base_3', 'First', 'MainFront'); gb.add('Base_2', 'First', 'MainMiddle'); gb.add('Base_1', 'First', 'MainBack'); });
game.on(game.CREATE, this, function() { console.log("Welcome to Game-Builder!"); require('rendering-bundle').create(); gb.add('Base_1', 'First', 'MainMiddle'); gb.add('Base_2', 'First', 'MainMiddle'); gb.add('Base_3', 'First', 'MainMiddle'); gb.add('Base_4', 'First', 'MainMiddle'); gb.addText('Text_1', 'First', 'Text', 'MainMiddle'); gb.addText('Text_2', 'First', 'Another text', 'MainMiddle'); gb.addText('Text_3', 'First', 'Yet more text', 'MainMiddle'); });
game.on(game.CREATE, this, function() { console.log("Welcome to Game-Builder!"); require('layering-bundle').create(); gb.add('Base_1', 'First', 'MainFront'); gb.add('Base_2', 'First', 'MainMiddle'); gb.add('Base_3', 'First', 'MainBack'); //These are used to add back the stuff to the layers if you //remove them while trying out the example. keyboard.onKeyDown(keyboard.A, this, function() { reclaimer.claimAll(); gb.add('Base_1', 'First', 'MainFront'); gb.add('Base_2', 'First', 'MainMiddle'); gb.add('Base_3', 'First', 'MainBack'); }); keyboard.onKeyDown(keyboard.S, this, function() { reclaimer.claimAll(); }); keyboard.onKeyDown(keyboard.Z, this, function() { reclaimer.claimOnly('configuration', ['Base_2']); }); keyboard.onKeyDown(keyboard.X, this, function() { reclaimer.claimOnly('type', ['Base']); }); keyboard.onKeyDown(keyboard.C, this, function() { reclaimer.claimAllBut('configuration', ['Base_2']); }); keyboard.onKeyDown(keyboard.P, this, function() { reclaimer.clearAllPools(); }); keyboard.onKeyDown(keyboard.O, this, function() { console.log( gb.goPool.toString() ); }); keyboard.onKeyDown(keyboard.I, this, function() { console.log( gb.coPool.toString() ); }); });
game.on(game.CREATE, this, function() { console.log("Welcome to Game-Builder!"); require('input-bundle').create(); require('viewports-bundle').create(); for (var i=0; i<20; i++) { var go = gb.add('Base_2', 'First', 'MainMiniFront'); go.x = util.rand_f(20, world.getWidth() - 20); go.y = util.rand_f(20, world.getHeight() - 20); go.renderer.color = util.rand_color(); } var minimapViewArea = gb.add('Frame', 'First', 'MiniFront'); var v = gb.viewports.get('Main'); keyboard.onKeyDown(keyboard.DOWN, this, function() { // Move the viewport v.y -= 10; // Lock the viewport from going past the world bounds to the bottom if (v.y < -world.getHeight()+minimapViewArea.renderer.height) v.y = -world.getHeight()+minimapViewArea.renderer.height; // Move the game object that represents the main viewport in the smaller viewport minimapViewArea.y = v.y*-1; }); keyboard.onKeyDown(keyboard.UP, this, function() { // Move the viewport v.y += 10; // Lock the viewport from going past the world bounds to the top if (v.y > 0) v.y = 0; // Move the game object that represents the main viewport in the smaller viewport minimapViewArea.y = v.y*-1; }); keyboard.onKeyDown(keyboard.RIGHT, this, function() { // Move the viewport v.x -= 10; // Lock the viewport from going past the world bounds to the right if (v.x < -world.getWidth()+minimapViewArea.renderer.width) v.x = -world.getWidth()+minimapViewArea.renderer.width; // Move the game object that represents the main viewport in the smaller viewport minimapViewArea.x = v.x*-1; }); keyboard.onKeyDown(keyboard.LEFT, this, function() { // Move the viewport v.x += 10; // Lock the viewport from going past the world bounds to the left if (v.x > 0) v.x = 0; // Move the game object that represents the main viewport in the smaller viewport minimapViewArea.x = v.x*-1; }); });
setupGameObjects: function() { var gridBundle = require('grid-bundle'); // Add Grid gb.add(gridBundle.getGridId(), editorConfig.getDefaultGroupName(), [{viewport:editorConfig.getGridViewportName(), layer:editorConfig.getDefaultLayerName()}]); }