clear: function() { // Claim all Game Objects and clean up the pools from instances gb.reclaimer.clearAllObjectsFromPools().now(); // Remove all update groups gb.groups.removeAll(); // Remove all Viewports gb.viewports.removeAll(); },
addOutline: function(viewportName) { viewportOutline.add({ viewportName: viewportName, gameObjectId: outlineBundle.getOutlineId(), updateGroup: editorConfig.getDefaultGroupName(), viewports: [ { viewport: viewportName, layer: editorConfig.getOutlineLayerName() } ], gameObjectArguments: { viewport: gb.viewports.get(viewportName) } }); },
setup: function(viewportName) { var viewport = gb.viewports.get(viewportName); viewport.addLayer(editorConfig.getDefaultLayerName()); viewport.addLayer(editorConfig.getOutlineLayerName()); viewport.addLayer(editorConfig.getGizmoCollidersBackLayerName()); viewport.addLayer(editorConfig.getGizmoCollidersFrontLayerName()); viewport.addLayer(editorConfig.getGizmoRotationBackLayerName()); viewport.addLayer(editorConfig.getGizmoRotationFrontLayerName()); viewport.addLayer(editorConfig.getGizmoScaleBackLayerName()); viewport.addLayer(editorConfig.getGizmoScaleFrontLayerName()); viewport.addLayer(editorConfig.getGizmoIconFrontLayerName()); viewport.hideLayer(editorConfig.getGizmoCollidersBackLayerName()); viewport.hideLayer(editorConfig.getGizmoCollidersFrontLayerName()); viewport.hideLayer(editorConfig.getGizmoRotationBackLayerName()); viewport.hideLayer(editorConfig.getGizmoRotationFrontLayerName()); viewport.hideLayer(editorConfig.getGizmoScaleBackLayerName()); viewport.hideLayer(editorConfig.getGizmoScaleFrontLayerName()); return viewport; },
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; }); });
get: function() { return gb.viewports.get(editorConfig.getMainViewportName()); }
state.addStartAction(function (levelIndex) { // Clear update groups and viewports before doing anything else gb.groups.removeAll(); gb.viewports.removeAll(); });