mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Renaming from State to Scene internally.
This is one monster update.
This commit is contained in:
parent
8bae761d75
commit
d804e056ed
140 changed files with 940 additions and 942 deletions
|
@ -15,7 +15,7 @@ var Map = require('../../structs/Map');
|
|||
*
|
||||
* Sprites and other Game Objects get the data they need from the AnimationManager.
|
||||
*
|
||||
* Access it via `state.anims`.
|
||||
* Access it via `scene.anims`.
|
||||
*
|
||||
* @class Phaser.AnimationManager
|
||||
* @constructor
|
||||
|
|
|
@ -41,7 +41,7 @@ var Config = new Class({
|
|||
this.canvas = GetValue(config, 'canvas', null);
|
||||
this.canvasStyle = GetValue(config, 'canvasStyle', null);
|
||||
|
||||
this.stateConfig = GetValue(config, 'state', null);
|
||||
this.sceneConfig = GetValue(config, 'scene', null);
|
||||
|
||||
this.seed = GetValue(config, 'seed', [ (Date.now() * Math.random()).toString() ]);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ var CreateRenderer = require('./CreateRenderer');
|
|||
var Data = require('../plugins/Data');
|
||||
var GlobalCache = require('../cache/GlobalCache');
|
||||
var GlobalInputManager = require('../input/GlobalInputManager');
|
||||
var GlobalStateManager = require('../state/GlobalStateManager');
|
||||
var GlobalSceneManager = require('../scene/GlobalSceneManager');
|
||||
var TextureManager = require('../textures/TextureManager');
|
||||
var TimeStep = require('./TimeStep');
|
||||
|
||||
|
@ -64,9 +64,9 @@ var Game = new Class({
|
|||
this.input = new GlobalInputManager(this, this.config);
|
||||
|
||||
/**
|
||||
* @property {Phaser.GlobalStateManager} state - The StateManager. Phaser instance specific.
|
||||
* @property {Phaser.GlobalSceneManager} scene - The SceneManager. Phaser instance specific.
|
||||
*/
|
||||
this.state = new GlobalStateManager(this, this.config.stateConfig);
|
||||
this.scene = new GlobalSceneManager(this, this.config.sceneConfig);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Device} device - Contains device information and capabilities (singleton)
|
||||
|
@ -100,7 +100,7 @@ var Game = new Class({
|
|||
|
||||
this.anims.boot(this.textures);
|
||||
|
||||
this.state.boot();
|
||||
this.scene.boot();
|
||||
|
||||
this.input.boot();
|
||||
|
||||
|
@ -120,18 +120,18 @@ var Game = new Class({
|
|||
|
||||
step: function (time, delta)
|
||||
{
|
||||
var active = this.state.active;
|
||||
var active = this.scene.active;
|
||||
var renderer = this.renderer;
|
||||
|
||||
// Global Managers (Time, Input, etc)
|
||||
|
||||
this.input.update(time, delta);
|
||||
|
||||
// States
|
||||
// Scenes
|
||||
|
||||
for (var i = 0; i < active.length; i++)
|
||||
{
|
||||
active[i].state.sys.step(time, delta);
|
||||
active[i].scene.sys.step(time, delta);
|
||||
}
|
||||
|
||||
// Render
|
||||
|
@ -140,10 +140,10 @@ var Game = new Class({
|
|||
|
||||
renderer.preRender();
|
||||
|
||||
// This uses active.length, in case state.update removed the state from the active list
|
||||
// This uses active.length, in case scene.update removed the scene from the active list
|
||||
for (i = 0; i < active.length; i++)
|
||||
{
|
||||
active[i].state.sys.render(0, renderer);
|
||||
active[i].scene.sys.render(0, renderer);
|
||||
}
|
||||
|
||||
renderer.postRender();
|
||||
|
@ -153,11 +153,11 @@ var Game = new Class({
|
|||
{
|
||||
this.loop.pause();
|
||||
|
||||
// var active = this.state.active;
|
||||
// var active = this.scene.active;
|
||||
|
||||
// for (var i = 0; i < active.length; i++)
|
||||
// {
|
||||
// active[i].state.sys.pause();
|
||||
// active[i].scene.sys.pause();
|
||||
// }
|
||||
},
|
||||
|
||||
|
@ -165,11 +165,11 @@ var Game = new Class({
|
|||
{
|
||||
this.loop.resume();
|
||||
|
||||
// var active = this.state.active;
|
||||
// var active = this.scene.active;
|
||||
|
||||
// for (var i = 0; i < active.length; i++)
|
||||
// {
|
||||
// active[i].state.sys.resume();
|
||||
// active[i].scene.sys.resume();
|
||||
// }
|
||||
},
|
||||
|
||||
|
|
|
@ -171,9 +171,9 @@ var Camera = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
setState: function (state)
|
||||
setScene: function (scene)
|
||||
{
|
||||
this.state = state;
|
||||
this.scene = scene;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -477,7 +477,7 @@ var Camera = new Class({
|
|||
|
||||
destroy: function ()
|
||||
{
|
||||
this.state = undefined;
|
||||
this.scene = undefined;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var CHECKSUM = {
|
||||
build: '8d1f7160-682b-11e7-b9b9-afea77e03fb0'
|
||||
build: 'de3f9290-689a-11e7-813e-ffb54ad43616'
|
||||
};
|
||||
module.exports = CHECKSUM;
|
|
@ -2,7 +2,7 @@ var GetAdvancedValue = require('../utils/object/GetAdvancedValue');
|
|||
var ScaleModes = require('../renderer/ScaleModes');
|
||||
var BlendModes = require('../renderer/BlendModes');
|
||||
|
||||
var BuildGameObject = function (state, gameObject, config)
|
||||
var BuildGameObject = function (scene, gameObject, config)
|
||||
{
|
||||
// Position
|
||||
|
||||
|
@ -89,13 +89,13 @@ var BuildGameObject = function (state, gameObject, config)
|
|||
|
||||
gameObject.visible = GetAdvancedValue(config, 'visible', true);
|
||||
|
||||
// Add to State
|
||||
// Add to Scene
|
||||
|
||||
var add = GetAdvancedValue(config, 'add', true);
|
||||
|
||||
if (add)
|
||||
{
|
||||
state.children.add(gameObject);
|
||||
scene.sys.displayList.add(gameObject);
|
||||
}
|
||||
|
||||
return gameObject;
|
||||
|
|
|
@ -17,9 +17,9 @@ var GameObject = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function GameObject (state, type)
|
||||
function GameObject (scene, type)
|
||||
{
|
||||
this.state = state;
|
||||
this.scene = scene;
|
||||
|
||||
this.type = type;
|
||||
|
||||
|
@ -39,8 +39,8 @@ var GameObject = new Class({
|
|||
this.hitArea = null;
|
||||
this.hitAreaCallback = null;
|
||||
|
||||
// Trigger a state z-depth sort
|
||||
this.state.sys.sortChildrenFlag = true;
|
||||
// Trigger a scene z-depth sort
|
||||
this.scene.sys.sortChildrenFlag = true;
|
||||
},
|
||||
|
||||
// For GameObject Pooling and item selection
|
||||
|
@ -58,7 +58,7 @@ var GameObject = new Class({
|
|||
|
||||
setHitArea: function (shape, callback)
|
||||
{
|
||||
this.state.sys.inputManager.setHitArea(this, shape, callback);
|
||||
this.scene.sys.inputManager.setHitArea(this, shape, callback);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
@ -73,7 +73,7 @@ var GameObject = new Class({
|
|||
{
|
||||
this.parent.remove(this);
|
||||
|
||||
this.state = undefined;
|
||||
this.scene = undefined;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
var ParseXMLBitmapFont = require('./ParseXMLBitmapFont');
|
||||
|
||||
var ParseFromAtlas = function (state, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing)
|
||||
var ParseFromAtlas = function (scene, fontName, textureKey, frameKey, xmlKey, xSpacing, ySpacing)
|
||||
{
|
||||
var frame = state.sys.textures.getFrame(textureKey, frameKey);
|
||||
var xml = state.sys.cache.xml.get(xmlKey);
|
||||
var frame = scene.sys.textures.getFrame(textureKey, frameKey);
|
||||
var xml = scene.sys.cache.xml.get(xmlKey);
|
||||
|
||||
if (frame && xml)
|
||||
{
|
||||
var data = ParseXMLBitmapFont(xml, xSpacing, ySpacing, frame);
|
||||
|
||||
state.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey });
|
||||
scene.sys.cache.bitmapFont.add(fontName, { data: data, texture: textureKey, frame: frameKey });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ var GetValue = require('../../utils/object/GetValue');
|
|||
// offset: { x: 0, y: 0 }
|
||||
// }
|
||||
|
||||
var ParseRetroFont = function (state, config)
|
||||
var ParseRetroFont = function (scene, config)
|
||||
{
|
||||
var w = config.width;
|
||||
var h = config.height;
|
||||
|
@ -38,7 +38,7 @@ var ParseRetroFont = function (state, config)
|
|||
|
||||
if (charsPerRow === null)
|
||||
{
|
||||
charsPerRow = state.sys.textures.getFrame(key).width / w;
|
||||
charsPerRow = scene.sys.textures.getFrame(key).width / w;
|
||||
|
||||
if (charsPerRow > letters.length)
|
||||
{
|
||||
|
|
|
@ -22,14 +22,14 @@ var DynamicBitmapText = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function DynamicBitmapText (state, x, y, font, text, size, align)
|
||||
function DynamicBitmapText (scene, x, y, font, text, size, align)
|
||||
{
|
||||
if (text === undefined) { text = ''; }
|
||||
if (align === undefined) { align = 'left'; }
|
||||
|
||||
GameObject.call(this, state, 'DynamicBitmapText');
|
||||
GameObject.call(this, scene, 'DynamicBitmapText');
|
||||
|
||||
this.fontData = this.state.sys.cache.bitmapFont.get(font);
|
||||
this.fontData = this.scene.sys.cache.bitmapFont.get(font);
|
||||
|
||||
this.text = (Array.isArray(text)) ? text.join('\n') : text;
|
||||
|
||||
|
|
|
@ -2,16 +2,16 @@ var BitmapText = require('./DynamicBitmapText');
|
|||
var GetAdvancedValue = require('../../../utils/object/GetAdvancedValue');
|
||||
var BuildGameObject = require('../../BuildGameObject');
|
||||
|
||||
var DynamicBitmapTextCreator = function (state, config)
|
||||
var DynamicBitmapTextCreator = function (scene, config)
|
||||
{
|
||||
var font = GetAdvancedValue(config, 'font', '');
|
||||
var text = GetAdvancedValue(config, 'text', '');
|
||||
var size = GetAdvancedValue(config, 'size', false);
|
||||
var align = GetAdvancedValue(config, 'align', 'left');
|
||||
|
||||
var bitmapText = new BitmapText(state, 0, 0, font, text, size, align);
|
||||
var bitmapText = new BitmapText(scene, 0, 0, font, text, size, align);
|
||||
|
||||
BuildGameObject(state, bitmapText, config);
|
||||
BuildGameObject(scene, bitmapText, config);
|
||||
|
||||
return bitmapText;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var BitmapText = require('./DynamicBitmapText');
|
||||
|
||||
var DynamicBitmapTextFactory = function (state, x, y, font, text, size, align)
|
||||
var DynamicBitmapTextFactory = function (scene, x, y, font, text, size, align)
|
||||
{
|
||||
return new BitmapText(state, x, y, font, text, size, align);
|
||||
return new BitmapText(scene, x, y, font, text, size, align);
|
||||
};
|
||||
|
||||
module.exports = DynamicBitmapTextFactory;
|
||||
|
|
|
@ -25,15 +25,15 @@ var BitmapText = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function BitmapText (state, x, y, font, text, size)
|
||||
function BitmapText (scene, x, y, font, text, size)
|
||||
{
|
||||
if (text === undefined) { text = ''; }
|
||||
|
||||
GameObject.call(this, state, 'BitmapText');
|
||||
GameObject.call(this, scene, 'BitmapText');
|
||||
|
||||
this.font = font;
|
||||
|
||||
var entry = this.state.sys.cache.bitmapFont.get(font);
|
||||
var entry = this.scene.sys.cache.bitmapFont.get(font);
|
||||
|
||||
this.fontData = entry.data;
|
||||
|
||||
|
|
|
@ -3,16 +3,16 @@ var BuildGameObject = require('../../BuildGameObject');
|
|||
var GetAdvancedValue = require('../../../utils/object/GetAdvancedValue');
|
||||
var GetValue = require('../../../utils/object/GetValue');
|
||||
|
||||
var BitmapTextCreator = function (state, config)
|
||||
var BitmapTextCreator = function (scene, config)
|
||||
{
|
||||
var font = GetValue(config, 'font', '');
|
||||
var text = GetAdvancedValue(config, 'text', '');
|
||||
var size = GetAdvancedValue(config, 'size', false);
|
||||
var align = GetValue(config, 'align', 'left');
|
||||
// var align = GetValue(config, 'align', 'left');
|
||||
|
||||
var bitmapText = new BitmapText(state, 0, 0, font, text, size);
|
||||
var bitmapText = new BitmapText(scene, 0, 0, font, text, size);
|
||||
|
||||
BuildGameObject(state, bitmapText, config);
|
||||
BuildGameObject(scene, bitmapText, config);
|
||||
|
||||
return bitmapText;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var BitmapText = require('./BitmapText');
|
||||
|
||||
var BitmapTextFactory = function (state, x, y, font, text, size)
|
||||
var BitmapTextFactory = function (scene, x, y, font, text, size)
|
||||
{
|
||||
return new BitmapText(state, x, y, font, text, size);
|
||||
return new BitmapText(scene, x, y, font, text, size);
|
||||
};
|
||||
|
||||
module.exports = BitmapTextFactory;
|
||||
|
|
|
@ -43,9 +43,9 @@ var Blitter = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Blitter (state, x, y, texture, frame)
|
||||
function Blitter (scene, x, y, texture, frame)
|
||||
{
|
||||
GameObject.call(this, state, 'Blitter');
|
||||
GameObject.call(this, scene, 'Blitter');
|
||||
|
||||
this.setTexture(texture, frame);
|
||||
this.setPosition(x, y);
|
||||
|
|
|
@ -2,14 +2,14 @@ var Blitter = require('./Blitter');
|
|||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
|
||||
var BlitterCreator = function (state, config)
|
||||
var BlitterCreator = function (scene, config)
|
||||
{
|
||||
var key = GetAdvancedValue(config, 'key', null);
|
||||
var frame = GetAdvancedValue(config, 'frame', null);
|
||||
|
||||
var blitter = new Blitter(state, 0, 0, key, frame);
|
||||
var blitter = new Blitter(scene, 0, 0, key, frame);
|
||||
|
||||
BuildGameObject(state, blitter, config);
|
||||
BuildGameObject(scene, blitter, config);
|
||||
|
||||
return blitter;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Blitter = require('./Blitter');
|
||||
|
||||
var BlitterFactory = function (state, x, y, key, frame)
|
||||
var BlitterFactory = function (scene, x, y, key, frame)
|
||||
{
|
||||
return new Blitter(state, x, y, key, frame);
|
||||
return new Blitter(scene, x, y, key, frame);
|
||||
};
|
||||
|
||||
module.exports = BlitterFactory;
|
||||
|
|
|
@ -13,7 +13,7 @@ var Animation = new Class({
|
|||
// Sprite / Game Object
|
||||
this.parent = parent;
|
||||
|
||||
this.animationManager = parent.state.sys.anims;
|
||||
this.animationManager = parent.scene.sys.anims;
|
||||
|
||||
this.animationManager.events.once('REMOVE_ANIMATION_EVENT', this.remove.bind(this));
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ var Texture = {
|
|||
|
||||
setTexture: function (key, frame)
|
||||
{
|
||||
this.texture = this.state.sys.textures.get(key);
|
||||
this.texture = this.scene.sys.textures.get(key);
|
||||
|
||||
this.frame = this.texture.get(frame);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ var Transform = {
|
|||
|
||||
set: function (value)
|
||||
{
|
||||
this.state.sys.sortChildrenFlag = true;
|
||||
this.scene.sys.sortChildrenFlag = true;
|
||||
this._z = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,12 @@ var EffectLayer = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function EffectLayer (state, x, y, width, height, effectName, fragmentShader)
|
||||
function EffectLayer (scene, x, y, width, height, effectName, fragmentShader)
|
||||
{
|
||||
GameObject.call(this, state, 'EffectLayer');
|
||||
GameObject.call(this, scene, 'EffectLayer');
|
||||
|
||||
var pot = ((width & (width - 1)) == 0 && (height & (height - 1)) == 0);
|
||||
var resourceManager = state.game.renderer.resourceManager;
|
||||
var resourceManager = scene.game.renderer.resourceManager;
|
||||
var wrap;
|
||||
var gl;
|
||||
|
||||
|
@ -45,7 +45,7 @@ var EffectLayer = new Class({
|
|||
|
||||
if (resourceManager !== undefined)
|
||||
{
|
||||
gl = state.game.renderer.gl;
|
||||
gl = scene.game.renderer.gl;
|
||||
wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
||||
this.dstShader = resourceManager.createShader(effectName, {
|
||||
vert: TexturedAndNormalizedTintedShader.vert,
|
||||
|
@ -61,7 +61,7 @@ var EffectLayer = new Class({
|
|||
);
|
||||
|
||||
this.dstRenderTarget = resourceManager.createRenderTarget(width, height, this.renderTexture, null);
|
||||
state.game.renderer.currentTexture = null; // force rebinding of prev texture
|
||||
scene.game.renderer.currentTexture = null; // force rebinding of prev texture
|
||||
}
|
||||
|
||||
this.flipY = true;
|
||||
|
|
|
@ -2,7 +2,7 @@ var EffectLayer = require('./EffectLayer');
|
|||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
|
||||
var EffectLayerCreator = function (state, config)
|
||||
var EffectLayerCreator = function (scene, config)
|
||||
{
|
||||
var x = GetAdvancedValue(config, 'x', 0);
|
||||
var y = GetAdvancedValue(config, 'y', 0);
|
||||
|
@ -11,9 +11,9 @@ var EffectLayerCreator = function (state, config)
|
|||
var key = GetAdvancedValue(config, 'key', null);
|
||||
var fragmentShader = GetAdvancedValue(config, 'fragmentShader', '');
|
||||
|
||||
var layer = new EffectLayer(state, x, y, width, height, effectName, fragmentShader);
|
||||
var layer = new EffectLayer(scene, x, y, width, height, effectName, fragmentShader);
|
||||
|
||||
BuildGameObject(state, layer, config);
|
||||
BuildGameObject(scene, layer, config);
|
||||
|
||||
return layer;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var EffectLayer = require('./EffectLayer');
|
||||
|
||||
var EffectLayerFactory = function (state, x, y, width, height, effectName, fragmentShader)
|
||||
var EffectLayerFactory = function (scene, x, y, width, height, effectName, fragmentShader)
|
||||
{
|
||||
return new EffectLayer(state, x, y, width, height, effectName, fragmentShader);
|
||||
return new EffectLayer(scene, x, y, width, height, effectName, fragmentShader);
|
||||
};
|
||||
|
||||
module.exports = EffectLayerFactory;
|
||||
|
|
|
@ -24,12 +24,12 @@ var Graphics = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Graphics (state, options)
|
||||
function Graphics (scene, options)
|
||||
{
|
||||
var x = GetValue(options, 'x', 0);
|
||||
var y = GetValue(options, 'y', 0);
|
||||
|
||||
GameObject.call(this, state, 'Graphics');
|
||||
GameObject.call(this, scene, 'Graphics');
|
||||
|
||||
this.setPosition(x, y);
|
||||
|
||||
|
@ -44,12 +44,12 @@ var Graphics = new Class({
|
|||
|
||||
this.setDefaultStyles(options);
|
||||
|
||||
var resourceManager = state.game.renderer.resourceManager;
|
||||
var resourceManager = scene.game.renderer.resourceManager;
|
||||
|
||||
if (resourceManager !== undefined)
|
||||
{
|
||||
this.resourceManager = resourceManager;
|
||||
this.gl = state.game.renderer.gl;
|
||||
this.gl = scene.game.renderer.gl;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -383,8 +383,8 @@ var Graphics = new Class({
|
|||
|
||||
generateTexture: function (key, width, height)
|
||||
{
|
||||
var screenWidth = this.state.game.config.width;
|
||||
var screenHeight = this.state.game.config.height;
|
||||
var screenWidth = this.scene.game.config.width;
|
||||
var screenHeight = this.scene.game.config.height;
|
||||
width = (typeof width === 'number') ? width : screenWidth;
|
||||
height = (typeof height === 'number') ? height : screenHeight;
|
||||
|
||||
|
@ -392,13 +392,13 @@ var Graphics = new Class({
|
|||
Graphics.TargetCamera.scrollX = this.x;
|
||||
Graphics.TargetCamera.scrollY = this.y;
|
||||
|
||||
var texture = this.state.game.textures.createCanvas(key, width, height);
|
||||
var texture = this.scene.game.textures.createCanvas(key, width, height);
|
||||
var ctx = texture.source[0].image.getContext('2d');
|
||||
texture.add('__BASE', 0, 0, 0, width, height);
|
||||
this.renderCanvas(this.state.game.renderer, this, 0, Graphics.TargetCamera, ctx);
|
||||
this.renderCanvas(this.scene.game.renderer, this, 0, Graphics.TargetCamera, ctx);
|
||||
if (this.gl)
|
||||
{
|
||||
this.state.game.renderer.uploadCanvasToGPU(ctx.canvas, texture.source[0].glTexture, true);
|
||||
this.scene.game.renderer.uploadCanvasToGPU(ctx.canvas, texture.source[0].glTexture, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
var Graphics = require('./Graphics');
|
||||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
|
||||
var GraphicsCreator = function (state, config)
|
||||
var GraphicsCreator = function (scene, config)
|
||||
{
|
||||
return new Graphics(state, config);
|
||||
return new Graphics(scene, config);
|
||||
};
|
||||
|
||||
module.exports = GraphicsCreator;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Graphics = require('./Graphics');
|
||||
|
||||
var GraphicsFactory = function (state, config)
|
||||
var GraphicsFactory = function (scene, config)
|
||||
{
|
||||
return new Graphics(state, config);
|
||||
return new Graphics(scene, config);
|
||||
};
|
||||
|
||||
module.exports = GraphicsFactory;
|
||||
|
|
|
@ -10,9 +10,9 @@ var Group = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Group (state, children, config)
|
||||
function Group (scene, children, config)
|
||||
{
|
||||
this.state = state;
|
||||
this.scene = scene;
|
||||
|
||||
this.children = new Set(children);
|
||||
|
||||
|
@ -64,13 +64,13 @@ var Group = new Class({
|
|||
{
|
||||
if (visible === undefined) { visible = true; }
|
||||
|
||||
var child = new this.classType(this.state, x, y, key, frame);
|
||||
var child = new this.classType(this.scene, x, y, key, frame);
|
||||
|
||||
this.state.sys.displayList.add(child);
|
||||
this.scene.sys.displayList.add(child);
|
||||
|
||||
if (child.preUpdate)
|
||||
{
|
||||
this.state.sys.updateList.add(child);
|
||||
this.scene.sys.updateList.add(child);
|
||||
}
|
||||
|
||||
child.visible = visible;
|
||||
|
@ -229,7 +229,7 @@ var Group = new Class({
|
|||
{
|
||||
this.children.clear();
|
||||
|
||||
this.state = undefined;
|
||||
this.scene = undefined;
|
||||
this.children = undefined;
|
||||
},
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Group = require('./Group');
|
||||
|
||||
var GroupCreator = function (state, config)
|
||||
var GroupCreator = function (scene, config)
|
||||
{
|
||||
return new Group(state, null, config);
|
||||
return new Group(scene, null, config);
|
||||
};
|
||||
|
||||
module.exports = GroupCreator;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Group = require('./Group');
|
||||
|
||||
var GroupFactory = function (state, children, config)
|
||||
var GroupFactory = function (scene, children, config)
|
||||
{
|
||||
return new Group(state, children, config);
|
||||
return new Group(scene, children, config);
|
||||
};
|
||||
|
||||
module.exports = GroupFactory;
|
||||
|
|
|
@ -27,9 +27,9 @@ var Image = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Image (state, x, y, texture, frame)
|
||||
function Image (scene, x, y, texture, frame)
|
||||
{
|
||||
GameObject.call(this, state, 'Image');
|
||||
GameObject.call(this, scene, 'Image');
|
||||
|
||||
this.setTexture(texture, frame);
|
||||
this.setPosition(x, y);
|
||||
|
|
|
@ -2,14 +2,14 @@ var Image = require('./Image');
|
|||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
|
||||
var ImageCreator = function (state, config)
|
||||
var ImageCreator = function (scene, config)
|
||||
{
|
||||
var key = GetAdvancedValue(config, 'key', null);
|
||||
var frame = GetAdvancedValue(config, 'frame', null);
|
||||
|
||||
var image = new Image(state, 0, 0, key, frame);
|
||||
var image = new Image(scene, 0, 0, key, frame);
|
||||
|
||||
BuildGameObject(state, image, config);
|
||||
BuildGameObject(scene, image, config);
|
||||
|
||||
return image;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Image = require('./Image');
|
||||
|
||||
var ImageFactory = function (state, x, y, key, frame)
|
||||
var ImageFactory = function (scene, x, y, key, frame)
|
||||
{
|
||||
return new Image(state, x, y, key, frame);
|
||||
return new Image(scene, x, y, key, frame);
|
||||
};
|
||||
|
||||
module.exports = ImageFactory;
|
||||
|
|
|
@ -26,9 +26,9 @@ var Mesh = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Mesh (state, x, y, vertices, uv, indices, colors, alphas, texture, frame)
|
||||
function Mesh (scene, x, y, vertices, uv, indices, colors, alphas, texture, frame)
|
||||
{
|
||||
GameObject.call(this, state, 'Mesh');
|
||||
GameObject.call(this, scene, 'Mesh');
|
||||
|
||||
this.setTexture(texture, frame);
|
||||
this.setPosition(x, y);
|
||||
|
|
|
@ -3,7 +3,7 @@ var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
|||
var GetValue = require('../../utils/object/GetValue');
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
|
||||
var MeshCreator = function (state, config)
|
||||
var MeshCreator = function (scene, config)
|
||||
{
|
||||
var key = GetAdvancedValue(config, 'key', null);
|
||||
var frame = GetAdvancedValue(config, 'frame', null);
|
||||
|
@ -13,9 +13,9 @@ var MeshCreator = function (state, config)
|
|||
var alphas = GetValue(config, 'alphas', []);
|
||||
var uv = GetValue(config, 'uv', []);
|
||||
|
||||
var mesh = new Mesh(state, 0, 0, vertices, uv, indices, colors, alphas, key, frame);
|
||||
var mesh = new Mesh(scene, 0, 0, vertices, uv, indices, colors, alphas, key, frame);
|
||||
|
||||
BuildGameObject(state, mesh, config);
|
||||
BuildGameObject(scene, mesh, config);
|
||||
|
||||
return mesh;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Mesh = require('./Mesh');
|
||||
|
||||
var MeshFactory = function (state, x, y, vertices, uv, key, frame)
|
||||
var MeshFactory = function (scene, x, y, vertices, uv, key, frame)
|
||||
{
|
||||
return new Mesh(state, x, y, vertices, uv, key, frame);
|
||||
return new Mesh(scene, x, y, vertices, uv, key, frame);
|
||||
};
|
||||
|
||||
module.exports = MeshFactory;
|
||||
|
|
|
@ -15,10 +15,10 @@ var ObjectPool = new Class({
|
|||
if (callbackScope === undefined) { callbackScope = this; }
|
||||
|
||||
this.manager = manager;
|
||||
this.state = manager.state;
|
||||
this.scene = manager.scene;
|
||||
|
||||
this.displayList = this.state.sys.displayList;
|
||||
this.updateList = this.state.sys.updateList;
|
||||
this.displayList = this.scene.sys.displayList;
|
||||
this.updateList = this.scene.sys.updateList;
|
||||
|
||||
this.createCallback = createCallback;
|
||||
this.callbackScope = callbackScope;
|
||||
|
@ -32,7 +32,7 @@ var ObjectPool = new Class({
|
|||
|
||||
makeGameObject: function ()
|
||||
{
|
||||
var gameObject = new this.classType(this.state);
|
||||
var gameObject = new this.classType(this.scene);
|
||||
|
||||
this.displayList.add(gameObject);
|
||||
|
||||
|
@ -215,7 +215,7 @@ var ObjectPool = new Class({
|
|||
destroy: function ()
|
||||
{
|
||||
this.manager = undefined;
|
||||
this.state = undefined;
|
||||
this.scene = undefined;
|
||||
|
||||
this.displayList = undefined;
|
||||
this.updateList = undefined;
|
||||
|
|
|
@ -23,7 +23,7 @@ var SpritePool = new Class({
|
|||
|
||||
makeSprite: function ()
|
||||
{
|
||||
var gameObject = new this.classType(this.state, 0, 0, this.defaultKey, this.defaultFrame);
|
||||
var gameObject = new this.classType(this.scene, 0, 0, this.defaultKey, this.defaultFrame);
|
||||
|
||||
this.displayList.add(gameObject);
|
||||
this.updateList.add(gameObject);
|
||||
|
|
|
@ -8,7 +8,7 @@ var Quad = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Quad (state, x, y, texture, frame)
|
||||
function Quad (scene, x, y, texture, frame)
|
||||
{
|
||||
// 0----3
|
||||
// |\ B|
|
||||
|
@ -25,7 +25,7 @@ var Quad = new Class({
|
|||
var colors = [ 0xffffff, 0xffffff, 0xffffff, 0xffffff ];
|
||||
var alphas = [ 1, 1, 1, 1 ];
|
||||
|
||||
Mesh.call(this, state, x, y, vertices, uv, indices, colors, alphas, texture, frame);
|
||||
Mesh.call(this, scene, x, y, vertices, uv, indices, colors, alphas, texture, frame);
|
||||
|
||||
this.resetPosition();
|
||||
},
|
||||
|
|
|
@ -2,16 +2,16 @@ var Quad = require('./Quad');
|
|||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
|
||||
var QuadCreator = function (state, config)
|
||||
var QuadCreator = function (scene, config)
|
||||
{
|
||||
var x = GetAdvancedValue(config, 'x', 0);
|
||||
var y = GetAdvancedValue(config, 'y', 0);
|
||||
var key = GetAdvancedValue(config, 'key', null);
|
||||
var frame = GetAdvancedValue(config, 'frame', null);
|
||||
|
||||
var quad = new Quad(state, x, y, key, frame);
|
||||
var quad = new Quad(scene, x, y, key, frame);
|
||||
|
||||
BuildGameObject(state, quad, config);
|
||||
BuildGameObject(scene, quad, config);
|
||||
|
||||
return quad;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Quad = require('./Quad');
|
||||
|
||||
var QuadFactory = function (state, x, y, key, frame)
|
||||
var QuadFactory = function (scene, x, y, key, frame)
|
||||
{
|
||||
return new Quad(state, x, y, key, frame);
|
||||
return new Quad(scene, x, y, key, frame);
|
||||
};
|
||||
|
||||
module.exports = QuadFactory;
|
||||
|
|
|
@ -33,16 +33,16 @@ var RenderPass = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function RenderPass (state, x, y, width, height, shaderName, fragmentShader)
|
||||
function RenderPass (scene, x, y, width, height, shaderName, fragmentShader)
|
||||
{
|
||||
GameObject.call(this, state, 'RenderPass');
|
||||
GameObject.call(this, scene, 'RenderPass');
|
||||
|
||||
var resourceManager = state.game.renderer.resourceManager;
|
||||
var resourceManager = scene.game.renderer.resourceManager;
|
||||
var pot = ((width & (width - 1)) == 0 && (height & (height - 1)) == 0);
|
||||
var gl;
|
||||
var wrap;
|
||||
|
||||
this.renderer = state.game.renderer;
|
||||
this.renderer = scene.game.renderer;
|
||||
this.passRenderTarget = null;
|
||||
this.renderTexture = null;
|
||||
this.passShader = null;
|
||||
|
@ -51,12 +51,12 @@ var RenderPass = new Class({
|
|||
|
||||
if (resourceManager !== undefined)
|
||||
{
|
||||
gl = state.game.renderer.gl;
|
||||
gl = scene.game.renderer.gl;
|
||||
wrap = pot ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
||||
this.passShader = resourceManager.createShader(shaderName, {vert: TexturedAndNormalizedTintedShader.vert, frag: fragmentShader});
|
||||
this.renderTexture = resourceManager.createTexture(0, gl.LINEAR, gl.LINEAR, wrap, wrap, gl.RGBA, null, width, height);
|
||||
this.passRenderTarget = resourceManager.createRenderTarget(width, height, this.renderTexture, null);
|
||||
state.game.renderer.currentTexture = null; // force rebinding of prev texture
|
||||
scene.game.renderer.currentTexture = null; // force rebinding of prev texture
|
||||
}
|
||||
|
||||
this.flipY = true;
|
||||
|
|
|
@ -2,7 +2,7 @@ var RenderPass = require('./RenderPass');
|
|||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
|
||||
var RenderPassCreator = function (state, config)
|
||||
var RenderPassCreator = function (scene, config)
|
||||
{
|
||||
var x = GetAdvancedValue(config, 'x', 0);
|
||||
var y = GetAdvancedValue(config, 'y', 0);
|
||||
|
@ -11,9 +11,9 @@ var RenderPassCreator = function (state, config)
|
|||
var shaderName = GetAdvancedValue(config, 'shaderName', '');
|
||||
var fragmentShader = GetAdvancedValue(config, 'fragmentShader', '');
|
||||
|
||||
var pass = new RenderPass(state, x, y, width, height, shaderName, fragmentShader);
|
||||
var pass = new RenderPass(scene, x, y, width, height, shaderName, fragmentShader);
|
||||
|
||||
BuildGameObject(state, pass, config);
|
||||
BuildGameObject(scene, pass, config);
|
||||
|
||||
return pass;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var RenderPass = require('./RenderPass');
|
||||
|
||||
var RenderPassFactory = function (state, x, y, width, height, shaderName, fragmentShader)
|
||||
var RenderPassFactory = function (scene, x, y, width, height, shaderName, fragmentShader)
|
||||
{
|
||||
return new RenderPass(state, x, y, width, height, shaderName, fragmentShader);
|
||||
return new RenderPass(scene, x, y, width, height, shaderName, fragmentShader);
|
||||
};
|
||||
|
||||
module.exports = RenderPassFactory;
|
||||
|
|
|
@ -27,9 +27,9 @@ var Sprite = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Sprite (state, x, y, texture, frame)
|
||||
function Sprite (scene, x, y, texture, frame)
|
||||
{
|
||||
GameObject.call(this, state, 'Sprite');
|
||||
GameObject.call(this, scene, 'Sprite');
|
||||
|
||||
this.anims = new Components.Animation(this);
|
||||
|
||||
|
|
|
@ -3,14 +3,14 @@ var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
|||
var BuildGameObject = require('../BuildGameObject');
|
||||
var BuildGameObjectAnimation = require('../BuildGameObjectAnimation');
|
||||
|
||||
var SpriteCreator = function (state, config)
|
||||
var SpriteCreator = function (scene, config)
|
||||
{
|
||||
var key = GetAdvancedValue(config, 'key', null);
|
||||
var frame = GetAdvancedValue(config, 'frame', null);
|
||||
|
||||
var sprite = new Sprite(state, 0, 0, key, frame);
|
||||
var sprite = new Sprite(scene, 0, 0, key, frame);
|
||||
|
||||
BuildGameObject(state, sprite, config);
|
||||
BuildGameObject(scene, sprite, config);
|
||||
|
||||
// Sprite specific config options:
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Sprite = require('./Sprite');
|
||||
|
||||
var SpriteFactory = function (state, x, y, key, frame)
|
||||
var SpriteFactory = function (scene, x, y, key, frame)
|
||||
{
|
||||
return new Sprite(state, x, y, key, frame);
|
||||
return new Sprite(scene, x, y, key, frame);
|
||||
};
|
||||
|
||||
module.exports = SpriteFactory;
|
||||
|
|
|
@ -28,13 +28,13 @@ var Text = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Text (state, x, y, text, style)
|
||||
function Text (scene, x, y, text, style)
|
||||
{
|
||||
if (x === undefined) { x = 0; }
|
||||
if (y === undefined) { y = 0; }
|
||||
if (text === undefined) { text = ''; }
|
||||
|
||||
GameObject.call(this, state, 'Text');
|
||||
GameObject.call(this, scene, 'Text');
|
||||
|
||||
this.setPosition(x, y);
|
||||
this.setOrigin(0, 0);
|
||||
|
|
|
@ -2,7 +2,7 @@ var Text = require('./Text');
|
|||
var GetAdvancedValue = require('../../../utils/object/GetAdvancedValue');
|
||||
var BuildGameObject = require('../../BuildGameObject');
|
||||
|
||||
var TextCreator = function (state, config)
|
||||
var TextCreator = function (scene, config)
|
||||
{
|
||||
// style Object = {
|
||||
// font: [ 'font', '16px Courier' ],
|
||||
|
@ -26,9 +26,9 @@ var TextCreator = function (state, config)
|
|||
var content = GetAdvancedValue(config, 'text', '');
|
||||
var style = GetAdvancedValue(config, 'style', null);
|
||||
|
||||
var text = new Text(state, 0, 0, content, style);
|
||||
var text = new Text(scene, 0, 0, content, style);
|
||||
|
||||
BuildGameObject(state, text, config);
|
||||
BuildGameObject(scene, text, config);
|
||||
|
||||
// Text specific config options:
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var Text = require('./Text');
|
||||
|
||||
var TextFactory = function (state, x, y, text, style)
|
||||
var TextFactory = function (scene, x, y, text, style)
|
||||
{
|
||||
return new Text(state, x, y, text, style);
|
||||
return new Text(scene, x, y, text, style);
|
||||
};
|
||||
|
||||
module.exports = TextFactory;
|
||||
|
|
|
@ -27,9 +27,9 @@ var Tilemap = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Tilemap (state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
function Tilemap (scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
{
|
||||
GameObject.call(this, state, 'Tilemap');
|
||||
GameObject.call(this, scene, 'Tilemap');
|
||||
|
||||
this.mapData = mapData !== null ? new Uint32Array(mapData) : new Uint32Array(mapWidth * mapHeight);
|
||||
this.tileWidth = tileWidth;
|
||||
|
|
|
@ -2,7 +2,7 @@ var Tilemap = require('./Tilemap');
|
|||
var GetValue = require('../../../utils/object/GetValue');
|
||||
var BuildGameObject = require('../../BuildGameObject');
|
||||
|
||||
var TilemapCreator = function (state, config)
|
||||
var TilemapCreator = function (scene, config)
|
||||
{
|
||||
var mapData = GetValue(config, 'map.data', null);
|
||||
var mapWidth = GetValue(config, 'map.width', 1);
|
||||
|
@ -17,9 +17,9 @@ var TilemapCreator = function (state, config)
|
|||
var tileFrame = GetValue(config, 'tile.frame', null);
|
||||
var tileBorder = GetValue(config, 'tile.border', 0);
|
||||
|
||||
var map = new Tilemap(state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, tileTexture, tileFrame);
|
||||
var map = new Tilemap(scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, tileTexture, tileFrame);
|
||||
|
||||
BuildGameObject(state, map, config);
|
||||
BuildGameObject(scene, map, config);
|
||||
|
||||
return map;
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
var Tilemap = require('./Tilemap');
|
||||
|
||||
var TilemapFactory = function (state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
var TilemapFactory = function (scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
{
|
||||
return new Tilemap(state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame);
|
||||
return new Tilemap(scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame);
|
||||
};
|
||||
|
||||
module.exports = TilemapFactory;
|
||||
|
|
|
@ -27,14 +27,14 @@ var StaticTilemap = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function StaticTilemap (state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
function StaticTilemap (scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
{
|
||||
GameObject.call(this, state, 'StaticTilemap');
|
||||
GameObject.call(this, scene, 'StaticTilemap');
|
||||
|
||||
this.vbo = null;
|
||||
this.gl = state.game.renderer.gl ? state.game.renderer.gl : null;
|
||||
this.tilemapRenderer = state.game.renderer.tilemapRenderer ? state.game.renderer.tilemapRenderer : null;
|
||||
this.resourceManager = this.gl ? state.game.renderer.resourceManager : null;
|
||||
this.gl = scene.game.renderer.gl ? scene.game.renderer.gl : null;
|
||||
this.tilemapRenderer = scene.game.renderer.tilemapRenderer ? scene.game.renderer.tilemapRenderer : null;
|
||||
this.resourceManager = this.gl ? scene.game.renderer.resourceManager : null;
|
||||
this.bufferData = null;
|
||||
this.mapData = mapData;
|
||||
this.tileWidth = tileWidth;
|
||||
|
|
|
@ -2,7 +2,7 @@ var StaticTilemap = require('./StaticTilemap');
|
|||
var GetValue = require('../../../utils/object/GetValue');
|
||||
var BuildGameObject = require('../../BuildGameObject');
|
||||
|
||||
var StaticTilemapCreator = function (state, config)
|
||||
var StaticTilemapCreator = function (scene, config)
|
||||
{
|
||||
var mapData = GetValue(config, 'map.data', null);
|
||||
var mapWidth = GetValue(config, 'map.width', 1);
|
||||
|
@ -17,9 +17,9 @@ var StaticTilemapCreator = function (state, config)
|
|||
var tileFrame = GetValue(config, 'tile.frame', null);
|
||||
var tileBorder = GetValue(config, 'tile.border', 0);
|
||||
|
||||
var map = new StaticTilemap(state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, tileTexture, tileFrame);
|
||||
var map = new StaticTilemap(scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, tileTexture, tileFrame);
|
||||
|
||||
BuildGameObject(state, map, config);
|
||||
BuildGameObject(scene, map, config);
|
||||
|
||||
return map;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var StaticTilemap = require('./StaticTilemap');
|
||||
|
||||
var StaticTilemapFactory = function (state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
var StaticTilemapFactory = function (scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
{
|
||||
return new StaticTilemap(state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame);
|
||||
return new StaticTilemap(scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame);
|
||||
};
|
||||
|
||||
module.exports = StaticTilemapFactory;
|
||||
|
|
|
@ -28,11 +28,11 @@ var TileSprite = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function TileSprite (state, x, y, width, height, texture, frame)
|
||||
function TileSprite (scene, x, y, width, height, texture, frame)
|
||||
{
|
||||
var resourceManager = state.game.renderer.resourceManager;
|
||||
var resourceManager = scene.game.renderer.resourceManager;
|
||||
|
||||
GameObject.call(this, state, 'TileSprite');
|
||||
GameObject.call(this, scene, 'TileSprite');
|
||||
|
||||
this.tilePositionX = 0;
|
||||
this.tilePositionY = 0;
|
||||
|
@ -68,8 +68,8 @@ var TileSprite = new Class({
|
|||
this.potHeight |= this.potHeight >> 16;
|
||||
this.potHeight++;
|
||||
|
||||
this.renderer = state.game.renderer;
|
||||
var gl = state.game.renderer.gl;
|
||||
this.renderer = scene.game.renderer;
|
||||
var gl = scene.game.renderer.gl;
|
||||
|
||||
this.tileTexture = resourceManager.createTexture(0, gl.LINEAR, gl.LINEAR, gl.REPEAT, gl.REPEAT, gl.RGBA, this.canvasBuffer, this.potWidth, this.potHeight);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ var TileSprite = require('./TileSprite');
|
|||
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
||||
var BuildGameObject = require('../BuildGameObject');
|
||||
|
||||
var TileSpriteCreator = function (state, config)
|
||||
var TileSpriteCreator = function (scene, config)
|
||||
{
|
||||
var x = GetAdvancedValue(config, 'x', 0);
|
||||
var y = GetAdvancedValue(config, 'y', 0);
|
||||
|
@ -11,9 +11,9 @@ var TileSpriteCreator = function (state, config)
|
|||
var key = GetAdvancedValue(config, 'key', '');
|
||||
var frame = GetAdvancedValue(config, 'frame', '');
|
||||
|
||||
var tile = new TileSprite(state, x, y, width, height, key, frame);
|
||||
var tile = new TileSprite(scene, x, y, width, height, key, frame);
|
||||
|
||||
BuildGameObject(state, tile, config);
|
||||
BuildGameObject(scene, tile, config);
|
||||
|
||||
return tile;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var TileSprite = require('./TileSprite');
|
||||
|
||||
var TileSpriteFactory = function (state, x, y, width, height, key, frame)
|
||||
var TileSpriteFactory = function (scene, x, y, width, height, key, frame)
|
||||
{
|
||||
return new TileSprite(state, x, y, width, height, key, frame);
|
||||
return new TileSprite(scene, x, y, width, height, key, frame);
|
||||
};
|
||||
|
||||
module.exports = TileSpriteFactory;
|
||||
|
|
|
@ -19,9 +19,9 @@ var Zone = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Zone (state, x, y, width, height)
|
||||
function Zone (scene, x, y, width, height)
|
||||
{
|
||||
GameObject.call(this, state, 'Zone');
|
||||
GameObject.call(this, scene, 'Zone');
|
||||
|
||||
this.setPosition(x, y);
|
||||
this.setSize(width, height);
|
||||
|
|
|
@ -7,12 +7,12 @@ var ZoneFactory = {
|
|||
|
||||
add: function (x, y, width, height)
|
||||
{
|
||||
return new Zone(this.state, x, y, width, height);
|
||||
return new Zone(this.scene, x, y, width, height);
|
||||
},
|
||||
|
||||
make: function (x, y, width, height)
|
||||
{
|
||||
return new Zone(this.state, x, y, width, height);
|
||||
return new Zone(this.scene, x, y, width, height);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ var BaseLoader = new Class({
|
|||
this.baseURL = '';
|
||||
this.path = '';
|
||||
|
||||
// Read from Game / State Config
|
||||
// Read from Game / Scene Config
|
||||
this.enableParallel = true;
|
||||
this.maxParallelDownloads = 4;
|
||||
|
||||
|
@ -39,7 +39,7 @@ var BaseLoader = new Class({
|
|||
this.queue = new Set();
|
||||
this.storage = new Set();
|
||||
|
||||
this._state = CONST.LOADER_IDLE;
|
||||
this.state = CONST.LOADER_IDLE;
|
||||
},
|
||||
|
||||
addFile: function (file)
|
||||
|
@ -59,18 +59,18 @@ var BaseLoader = new Class({
|
|||
// Is the Loader actively loading (or processing loaded files)
|
||||
isLoading: function ()
|
||||
{
|
||||
return (this._state === CONST.LOADER_LOADING || this._state === CONST.LOADER_PROCESSING);
|
||||
return (this.state === CONST.LOADER_LOADING || this.state === CONST.LOADER_PROCESSING);
|
||||
},
|
||||
|
||||
// Is the Loader ready to start a new load?
|
||||
isReady: function ()
|
||||
{
|
||||
return (this._state === CONST.LOADER_IDLE || this._state === CONST.LOADER_COMPLETE || this._state === CONST.LOADER_FAILED);
|
||||
return (this.state === CONST.LOADER_IDLE || this.state === CONST.LOADER_COMPLETE || this.state === CONST.LOADER_FAILED);
|
||||
},
|
||||
|
||||
start: function ()
|
||||
{
|
||||
console.log(this.state.sys.settings.key, '- BaseLoader start. Files to load:', this.list.size);
|
||||
console.log(this.scene.sys.settings.key, '- BaseLoader start. Files to load:', this.list.size);
|
||||
|
||||
if (!this.isReady())
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ var BaseLoader = new Class({
|
|||
}
|
||||
else
|
||||
{
|
||||
this._state = CONST.LOADER_LOADING;
|
||||
this.state = CONST.LOADER_LOADING;
|
||||
|
||||
this.failed.clear();
|
||||
this.inflight.clear();
|
||||
|
@ -180,7 +180,7 @@ var BaseLoader = new Class({
|
|||
{
|
||||
// console.log('---> BaseLoader.finishedLoading PROCESSING', this.queue.size, 'files');
|
||||
|
||||
this._state = CONST.LOADER_PROCESSING;
|
||||
this.state = CONST.LOADER_PROCESSING;
|
||||
|
||||
this.storage.clear();
|
||||
|
||||
|
@ -241,7 +241,7 @@ var BaseLoader = new Class({
|
|||
{
|
||||
this.queue.delete(file);
|
||||
|
||||
if (this.queue.size === 0 && this._state === CONST.LOADER_PROCESSING)
|
||||
if (this.queue.size === 0 && this.state === CONST.LOADER_PROCESSING)
|
||||
{
|
||||
// We've processed all the files we loaded
|
||||
this.processComplete();
|
||||
|
@ -250,7 +250,7 @@ var BaseLoader = new Class({
|
|||
|
||||
processComplete: function ()
|
||||
{
|
||||
console.log(this.state.sys.settings.key, '- Loader Complete. Loaded:', this.storage.size, 'Failed:', this.failed.size);
|
||||
console.log(this.scene.sys.settings.key, '- Loader Complete. Loaded:', this.storage.size, 'Failed:', this.failed.size);
|
||||
|
||||
this.list.clear();
|
||||
this.inflight.clear();
|
||||
|
@ -261,7 +261,7 @@ var BaseLoader = new Class({
|
|||
this.processCallback();
|
||||
}
|
||||
|
||||
this._state = CONST.LOADER_COMPLETE;
|
||||
this.state = CONST.LOADER_COMPLETE;
|
||||
|
||||
this.events.dispatch(new Event.LOADER_COMPLETE_EVENT(this));
|
||||
},
|
||||
|
@ -281,13 +281,13 @@ var BaseLoader = new Class({
|
|||
this.path = '';
|
||||
this.baseURL = '';
|
||||
|
||||
this._state = CONST.LOADER_IDLE;
|
||||
this.state = CONST.LOADER_IDLE;
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
this.reset();
|
||||
this._state = CONST.LOADER_DESTROYED;
|
||||
this.state = CONST.LOADER_DESTROYED;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@ var Phaser = {
|
|||
|
||||
GameObjects: require('./gameobjects'),
|
||||
|
||||
State: require('./state/State'),
|
||||
Scene: require('./scene/Scene'),
|
||||
|
||||
Loader: {
|
||||
|
||||
|
|
|
@ -8,18 +8,18 @@ var CameraManager = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function CameraManager (state)
|
||||
function CameraManager (scene)
|
||||
{
|
||||
// The State that owns this plugin
|
||||
this.state = state;
|
||||
// The Scene that owns this plugin
|
||||
this.scene = scene;
|
||||
|
||||
this.cameras = [];
|
||||
this.cameraPool = [];
|
||||
|
||||
if (state.sys.settings.cameras)
|
||||
if (scene.sys.settings.cameras)
|
||||
{
|
||||
// We have cameras to create
|
||||
this.fromJSON(state.sys.settings.cameras);
|
||||
this.fromJSON(scene.sys.settings.cameras);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -64,8 +64,8 @@ var CameraManager = new Class({
|
|||
config = [ config ];
|
||||
}
|
||||
|
||||
var gameWidth = this.state.sys.game.config.width;
|
||||
var gameHeight = this.state.sys.game.config.height;
|
||||
var gameWidth = this.scene.sys.game.config.width;
|
||||
var gameHeight = this.scene.sys.game.config.height;
|
||||
|
||||
for (var i = 0; i < config.length; i++)
|
||||
{
|
||||
|
@ -117,8 +117,8 @@ var CameraManager = new Class({
|
|||
{
|
||||
if (x === undefined) { x = 0; }
|
||||
if (y === undefined) { y = 0; }
|
||||
if (width === undefined) { width = this.state.sys.game.config.width; }
|
||||
if (height === undefined) { height = this.state.sys.game.config.height; }
|
||||
if (width === undefined) { width = this.scene.sys.game.config.width; }
|
||||
if (height === undefined) { height = this.scene.sys.game.config.height; }
|
||||
|
||||
var camera = null;
|
||||
|
||||
|
@ -132,7 +132,7 @@ var CameraManager = new Class({
|
|||
camera = new Camera(x, y, width, height);
|
||||
}
|
||||
|
||||
camera.setState(this.state);
|
||||
camera.setScene(this.scene);
|
||||
|
||||
this.cameras.push(camera);
|
||||
|
||||
|
@ -203,7 +203,7 @@ var CameraManager = new Class({
|
|||
|
||||
camera.preRender();
|
||||
|
||||
renderer.render(this.state, children, interpolation, camera);
|
||||
renderer.render(this.scene, children, interpolation, camera);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -223,7 +223,7 @@ var CameraManager = new Class({
|
|||
|
||||
this.cameras = [];
|
||||
this.cameraPool = [];
|
||||
this.state = undefined;
|
||||
this.scene = undefined;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -4,10 +4,10 @@ var DisplayList = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function DisplayList (state)
|
||||
function DisplayList (scene)
|
||||
{
|
||||
// The State that owns this plugin
|
||||
this.state = state;
|
||||
// The Scene that owns this plugin
|
||||
this.scene = scene;
|
||||
|
||||
// The objects that belong to this collection.
|
||||
// The equivalent of the old `Sprite.children` array.
|
||||
|
@ -18,7 +18,7 @@ var DisplayList = new Class({
|
|||
|
||||
add: function (child)
|
||||
{
|
||||
if (child.parent === this.state)
|
||||
if (child.parent === this.scene)
|
||||
{
|
||||
return child;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ var DisplayList = new Class({
|
|||
child.parent.children.remove(child);
|
||||
}
|
||||
|
||||
child.parent = this.state;
|
||||
child.parent = this.scene;
|
||||
|
||||
this.list.push(child);
|
||||
|
||||
|
@ -50,7 +50,7 @@ var DisplayList = new Class({
|
|||
child.parent.children.remove(child);
|
||||
}
|
||||
|
||||
child.parent = this.state;
|
||||
child.parent = this.scene;
|
||||
|
||||
this.list.splice(index, 0, child);
|
||||
}
|
||||
|
@ -328,7 +328,7 @@ var DisplayList = new Class({
|
|||
{
|
||||
return false;
|
||||
}
|
||||
else if (child.parent === this.state)
|
||||
else if (child.parent === this.scene)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ var DisplayList = new Class({
|
|||
*/
|
||||
bringToTop: function (child)
|
||||
{
|
||||
if (child.parent === this.state && this.getIndex(child) < this.list.length)
|
||||
if (child.parent === this.scene && this.getIndex(child) < this.list.length)
|
||||
{
|
||||
this.remove(child);
|
||||
this.add(child);
|
||||
|
@ -365,7 +365,7 @@ var DisplayList = new Class({
|
|||
*/
|
||||
sendToBack: function (child)
|
||||
{
|
||||
if (child.parent === this.state && this.getIndex(child) > 0)
|
||||
if (child.parent === this.scene && this.getIndex(child) > 0)
|
||||
{
|
||||
this.remove(child);
|
||||
this.addAt(child, 0);
|
||||
|
@ -573,7 +573,7 @@ var DisplayList = new Class({
|
|||
*/
|
||||
reparent: function (newParent)
|
||||
{
|
||||
if (newParent !== this.state)
|
||||
if (newParent !== this.scene)
|
||||
{
|
||||
for (var i = 0; i < this.list.length; i++)
|
||||
{
|
||||
|
|
|
@ -20,84 +20,84 @@ var GameObjectCreator = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function GameObjectCreator (state)
|
||||
function GameObjectCreator (scene)
|
||||
{
|
||||
this.state = state;
|
||||
this.scene = scene;
|
||||
},
|
||||
|
||||
bitmapText: function (config)
|
||||
{
|
||||
return StaticBitmapTextCreator(this.state, config);
|
||||
return StaticBitmapTextCreator(this.scene, config);
|
||||
},
|
||||
|
||||
dynamicBitmapText: function (config)
|
||||
{
|
||||
return DynamicBitmapTextCreator(this.state, config);
|
||||
return DynamicBitmapTextCreator(this.scene, config);
|
||||
},
|
||||
|
||||
blitter: function (config)
|
||||
{
|
||||
return BlitterCreator(this.state, config);
|
||||
return BlitterCreator(this.scene, config);
|
||||
},
|
||||
|
||||
effectLayer: function (config)
|
||||
{
|
||||
return EffectLayerCreator(this.state, config);
|
||||
return EffectLayerCreator(this.scene, config);
|
||||
},
|
||||
|
||||
graphics: function (config)
|
||||
{
|
||||
return GraphicsCreator(this.state, config);
|
||||
return GraphicsCreator(this.scene, config);
|
||||
},
|
||||
|
||||
group: function (config)
|
||||
{
|
||||
return GroupCreator(this.state, config);
|
||||
return GroupCreator(this.scene, config);
|
||||
},
|
||||
|
||||
mesh: function (config)
|
||||
{
|
||||
return MeshCreator(this.state, config);
|
||||
return MeshCreator(this.scene, config);
|
||||
},
|
||||
|
||||
image: function (config)
|
||||
{
|
||||
return ImageCreator(this.state, config);
|
||||
return ImageCreator(this.scene, config);
|
||||
},
|
||||
|
||||
quad: function (config)
|
||||
{
|
||||
return QuadCreator(this.state, config);
|
||||
return QuadCreator(this.scene, config);
|
||||
},
|
||||
|
||||
renderPass: function (config)
|
||||
{
|
||||
return RenderPassCreator(this.state, config);
|
||||
return RenderPassCreator(this.scene, config);
|
||||
},
|
||||
|
||||
sprite: function (config)
|
||||
{
|
||||
return SpriteCreator(this.state, config);
|
||||
return SpriteCreator(this.scene, config);
|
||||
},
|
||||
|
||||
text: function (config)
|
||||
{
|
||||
return TextCreator(this.state, config);
|
||||
return TextCreator(this.scene, config);
|
||||
},
|
||||
|
||||
tilemap: function (config)
|
||||
{
|
||||
return DynamicTilemapCreator(this.state, config);
|
||||
return DynamicTilemapCreator(this.scene, config);
|
||||
},
|
||||
|
||||
staticTilemap: function (config)
|
||||
{
|
||||
return StaticTilemapCreator(this.state, config);
|
||||
return StaticTilemapCreator(this.scene, config);
|
||||
},
|
||||
|
||||
tileSprite: function (config)
|
||||
{
|
||||
return TileSpriteCreator(this.state, config);
|
||||
return TileSpriteCreator(this.scene, config);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -20,12 +20,12 @@ var GameObjectFactory = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function GameObjectFactory (state)
|
||||
function GameObjectFactory (scene)
|
||||
{
|
||||
this.state = state;
|
||||
this.scene = scene;
|
||||
|
||||
this.displayList = state.sys.displayList;
|
||||
this.updateList = state.sys.updateList;
|
||||
this.displayList = scene.sys.displayList;
|
||||
this.updateList = scene.sys.updateList;
|
||||
},
|
||||
|
||||
existing: function (child)
|
||||
|
@ -45,57 +45,57 @@ var GameObjectFactory = new Class({
|
|||
|
||||
bitmapText: function (x, y, font, text, size, align)
|
||||
{
|
||||
return this.displayList.add(StaticBitmapTextFactory(this.state, x, y, font, text, size, align));
|
||||
return this.displayList.add(StaticBitmapTextFactory(this.scene, x, y, font, text, size, align));
|
||||
},
|
||||
|
||||
dynamicBitmapText: function (x, y, font, text, size, align)
|
||||
{
|
||||
return this.displayList.add(DynamicBitmapTextFactory(this.state, x, y, font, text, size, align));
|
||||
return this.displayList.add(DynamicBitmapTextFactory(this.scene, x, y, font, text, size, align));
|
||||
},
|
||||
|
||||
blitter: function (x, y, key, frame)
|
||||
{
|
||||
return this.displayList.add(BlitterFactory(this.state, x, y, key, frame));
|
||||
return this.displayList.add(BlitterFactory(this.scene, x, y, key, frame));
|
||||
},
|
||||
|
||||
effectLayer: function (x, y, width, height, effectName, fragmentShader)
|
||||
{
|
||||
return this.displayList.add(EffectLayerFactory(this.state, x, y, width, height, effectName, fragmentShader));
|
||||
return this.displayList.add(EffectLayerFactory(this.scene, x, y, width, height, effectName, fragmentShader));
|
||||
},
|
||||
|
||||
graphics: function (config)
|
||||
{
|
||||
return this.displayList.add(GraphicsFactory(this.state, config));
|
||||
return this.displayList.add(GraphicsFactory(this.scene, config));
|
||||
},
|
||||
|
||||
group: function (displayList, config)
|
||||
{
|
||||
return GroupFactory(this.state, displayList, config);
|
||||
return GroupFactory(this.scene, displayList, config);
|
||||
},
|
||||
|
||||
image: function (x, y, key, frame)
|
||||
{
|
||||
return this.displayList.add(ImageFactory(this.state, x, y, key, frame));
|
||||
return this.displayList.add(ImageFactory(this.scene, x, y, key, frame));
|
||||
},
|
||||
|
||||
mesh: function (x, y, vertices, uv, key, frame)
|
||||
{
|
||||
return this.displayList.add(MeshFactory(this.state, x, y, vertices, uv, key, frame));
|
||||
return this.displayList.add(MeshFactory(this.scene, x, y, vertices, uv, key, frame));
|
||||
},
|
||||
|
||||
quad: function (x, y, key, frame)
|
||||
{
|
||||
return this.displayList.add(QuadFactory(this.state, x, y, key, frame));
|
||||
return this.displayList.add(QuadFactory(this.scene, x, y, key, frame));
|
||||
},
|
||||
|
||||
renderPass: function (x, y, width, height, shaderName, fragmentShader)
|
||||
{
|
||||
return this.displayList.add(RenderPassFactory(this.state, x, y, width, height, shaderName, fragmentShader));
|
||||
return this.displayList.add(RenderPassFactory(this.scene, x, y, width, height, shaderName, fragmentShader));
|
||||
},
|
||||
|
||||
sprite: function (x, y, key, frame)
|
||||
{
|
||||
var sprite = SpriteFactory(this.state, x, y, key, frame);
|
||||
var sprite = SpriteFactory(this.scene, x, y, key, frame);
|
||||
|
||||
this.displayList.add(sprite);
|
||||
this.updateList.add(sprite);
|
||||
|
@ -105,22 +105,22 @@ var GameObjectFactory = new Class({
|
|||
|
||||
text: function (x, y, text, style)
|
||||
{
|
||||
return this.displayList.add(TextFactory(this.state, x, y, text, style));
|
||||
return this.displayList.add(TextFactory(this.scene, x, y, text, style));
|
||||
},
|
||||
|
||||
tilemap: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
{
|
||||
return this.displayList.add(DynamicTilemapFactory(this.state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
|
||||
return this.displayList.add(DynamicTilemapFactory(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
|
||||
},
|
||||
|
||||
staticTilemap: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||
{
|
||||
return this.displayList.add(StaticTilemapFactory(this.state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
|
||||
return this.displayList.add(StaticTilemapFactory(this.scene, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
|
||||
},
|
||||
|
||||
tileSprite: function (x, y, width, height, key, frame)
|
||||
{
|
||||
return this.displayList.add(TileSpriteFactory(this.state, x, y, width, height, key, frame));
|
||||
return this.displayList.add(TileSpriteFactory(this.scene, x, y, width, height, key, frame));
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -5,17 +5,17 @@ var InputManager = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function InputManager (state, game)
|
||||
function InputManager (scene, game)
|
||||
{
|
||||
// The State that owns this plugin
|
||||
this.state = state;
|
||||
// The Scene that owns this plugin
|
||||
this.scene = scene;
|
||||
|
||||
this.cameras;
|
||||
|
||||
// GlobalInputManager
|
||||
this.manager = game.input;
|
||||
|
||||
// Should use State event dispatcher?
|
||||
// Should use Scene event dispatcher?
|
||||
this.events = this.manager.events;
|
||||
|
||||
this.keyboard = this.manager.keyboard;
|
||||
|
@ -36,7 +36,7 @@ var InputManager = new Class({
|
|||
|
||||
boot: function ()
|
||||
{
|
||||
this.cameras = this.state.sys.cameras.cameras;
|
||||
this.cameras = this.scene.sys.cameras.cameras;
|
||||
},
|
||||
|
||||
begin: function ()
|
||||
|
@ -90,7 +90,7 @@ var InputManager = new Class({
|
|||
return;
|
||||
}
|
||||
|
||||
// Has the pointer moved? If so we need to re-check the interactive objects per camera in this State
|
||||
// Has the pointer moved? If so we need to re-check the interactive objects per camera in this Scene
|
||||
if (this.manager.activePointer.dirty)
|
||||
{
|
||||
this.hitTestPointer(this.manager.activePointer);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var BaseLoader = require('../loader/BaseLoader');
|
||||
var Class = require('../utils/Class');
|
||||
var CONST = require('../loader/const');
|
||||
// var CONST = require('../loader/const');
|
||||
var NumberArray = require('../utils/array/NumberArray');
|
||||
|
||||
var AnimationJSONFile = require('../loader/filetypes/AnimationJSONFile');
|
||||
|
@ -25,15 +25,15 @@ var Loader = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Loader (state)
|
||||
function Loader (scene)
|
||||
{
|
||||
BaseLoader.call(this);
|
||||
|
||||
/**
|
||||
* @property {Phaser.State} state - The State that owns this Factory
|
||||
* @property {Phaser.Scene} scene - The Scene that owns this Factory
|
||||
* @protected
|
||||
*/
|
||||
this.state = state;
|
||||
this.scene = scene;
|
||||
|
||||
this._multilist = {};
|
||||
},
|
||||
|
@ -248,9 +248,9 @@ var Loader = new Class({
|
|||
}
|
||||
|
||||
// The global Texture Manager
|
||||
var cache = this.state.sys.cache;
|
||||
var textures = this.state.sys.textures;
|
||||
var anims = this.state.sys.anims;
|
||||
var cache = this.scene.sys.cache;
|
||||
var textures = this.scene.sys.textures;
|
||||
var anims = this.scene.sys.anims;
|
||||
|
||||
// Process multiatlas groups first
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ var PoolManager = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function PoolManager (state)
|
||||
function PoolManager (scene)
|
||||
{
|
||||
this.state = state;
|
||||
this.scene = scene;
|
||||
|
||||
this._active = [];
|
||||
this._pendingInsertion = [];
|
||||
|
@ -102,7 +102,7 @@ var PoolManager = new Class({
|
|||
this.processing = false;
|
||||
},
|
||||
|
||||
// State that owns this Pool is shutting down
|
||||
// Scene that owns this Pool is shutting down
|
||||
shutdown: function ()
|
||||
{
|
||||
var i;
|
||||
|
@ -132,7 +132,7 @@ var PoolManager = new Class({
|
|||
{
|
||||
this.shutdown();
|
||||
|
||||
this.state = undefined;
|
||||
this.scene = undefined;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
var Class = require('../utils/Class');
|
||||
|
||||
// A proxy class to the Global State Manager
|
||||
var StateManager = new Class({
|
||||
// A proxy class to the Global Scene Manager
|
||||
var SceneManager = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
function StateManager (state, game)
|
||||
function SceneManager (scene, game)
|
||||
{
|
||||
// The State that owns this plugin
|
||||
this.state = state;
|
||||
// The Scene that owns this plugin
|
||||
this.scene = scene;
|
||||
|
||||
this.settings = state.sys.settings;
|
||||
this.settings = scene.sys.settings;
|
||||
|
||||
this.key = state.sys.settings.key;
|
||||
this.key = scene.sys.settings.key;
|
||||
|
||||
// GlobalStateManager
|
||||
this.manager = game.state;
|
||||
// GlobalSceneManager
|
||||
this.manager = game.scene;
|
||||
|
||||
// Private
|
||||
this._queue = [];
|
||||
|
@ -101,7 +101,7 @@ var StateManager = new Class({
|
|||
this._queue.length = 0;
|
||||
},
|
||||
|
||||
// Shutdown this State and run the given one
|
||||
// Shutdown this Scene and run the given one
|
||||
start: function (key, data)
|
||||
{
|
||||
if (key === undefined) { key = this.key; }
|
||||
|
@ -111,15 +111,15 @@ var StateManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Add the State into the State Manager and start it if 'autoStart' is true or the State config 'active' property is set
|
||||
add: function (key, stateConfig, autoStart)
|
||||
// Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set
|
||||
add: function (key, sceneConfig, autoStart)
|
||||
{
|
||||
this._queue.push({ type: 'add', key: key, data: stateConfig, autoStart: autoStart });
|
||||
this._queue.push({ type: 'add', key: key, data: sceneConfig, autoStart: autoStart });
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
// Launch the given State and run it in parallel with this one
|
||||
// Launch the given Scene and run it in parallel with this one
|
||||
launch: function (key, data)
|
||||
{
|
||||
if (key === undefined) { key = this.key; }
|
||||
|
@ -129,7 +129,7 @@ var StateManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Pause the State - this stops the update step from happening but it still renders
|
||||
// Pause the Scene - this stops the update step from happening but it still renders
|
||||
pause: function (key)
|
||||
{
|
||||
if (key === undefined) { key = this.key; }
|
||||
|
@ -139,7 +139,7 @@ var StateManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Resume the State - starts the update loop again
|
||||
// Resume the Scene - starts the update loop again
|
||||
resume: function (key)
|
||||
{
|
||||
if (key === undefined) { key = this.key; }
|
||||
|
@ -149,7 +149,7 @@ var StateManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Makes the State sleep (no update, no render) but doesn't shutdown
|
||||
// Makes the Scene sleep (no update, no render) but doesn't shutdown
|
||||
sleep: function (key)
|
||||
{
|
||||
this._queue.push({ type: 'sleep', key: key });
|
||||
|
@ -157,7 +157,7 @@ var StateManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Makes the State wake-up (starts update and render)
|
||||
// Makes the Scene wake-up (starts update and render)
|
||||
wake: function (key)
|
||||
{
|
||||
this._queue.push({ type: 'wake', key: key });
|
||||
|
@ -165,7 +165,7 @@ var StateManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Makes this State sleep then starts the State given
|
||||
// Makes this Scene sleep then starts the Scene given
|
||||
swap: function (key)
|
||||
{
|
||||
this._queue.push({ type: 'swap', key: key });
|
||||
|
@ -173,7 +173,7 @@ var StateManager = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
// Shutdown the State, clearing display list, timers, etc
|
||||
// Shutdown the Scene, clearing display list, timers, etc
|
||||
stop: function (key)
|
||||
{
|
||||
if (key === undefined) { key = this.key; }
|
||||
|
@ -217,7 +217,7 @@ var StateManager = new Class({
|
|||
|
||||
get: function (key)
|
||||
{
|
||||
return this.manager.getState(key);
|
||||
return this.manager.getScene(key);
|
||||
},
|
||||
|
||||
transitionTo: function (key, duration)
|
||||
|
@ -233,4 +233,4 @@ var StateManager = new Class({
|
|||
|
||||
});
|
||||
|
||||
module.exports = StateManager;
|
||||
module.exports = SceneManager;
|
|
@ -4,9 +4,9 @@ var UpdateList = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function UpdateList (state)
|
||||
function UpdateList (scene)
|
||||
{
|
||||
this.state = state;
|
||||
this.scene = scene;
|
||||
|
||||
this._list = [];
|
||||
this._pendingInsertion = [];
|
||||
|
@ -69,7 +69,7 @@ var UpdateList = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
// State that owns this Clock is shutting down
|
||||
// Scene that owns this Clock is shutting down
|
||||
shutdown: function ()
|
||||
{
|
||||
var i;
|
||||
|
@ -99,7 +99,7 @@ var UpdateList = new Class({
|
|||
{
|
||||
this.shutdown();
|
||||
|
||||
this.state = undefined;
|
||||
this.scene = undefined;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ var CanvasRenderer = new Class({
|
|||
|
||||
this.drawCount = 0;
|
||||
|
||||
// Read all the following from game config (or State config?)
|
||||
// Read all the following from game config (or Scene config?)
|
||||
// this.clearBeforeRender = true;
|
||||
// this.transparent = false;
|
||||
// this.autoResize = false;
|
||||
|
@ -148,20 +148,20 @@ var CanvasRenderer = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Renders the State.
|
||||
* Renders the Scene.
|
||||
*
|
||||
* @method render
|
||||
* @param {Phaser.State} state - The State to be rendered.
|
||||
* @param {Phaser.Scene} scene - The Scene to be rendered.
|
||||
* @param {number} interpolationPercentage - The cumulative amount of time that hasn't been simulated yet, divided
|
||||
* by the amount of time that will be simulated the next time update()
|
||||
* runs. Useful for interpolating frames.
|
||||
*/
|
||||
render: function (state, children, interpolationPercentage, camera)
|
||||
render: function (scene, children, interpolationPercentage, camera)
|
||||
{
|
||||
var w = state.sys.width;
|
||||
var h = state.sys.height;
|
||||
var ctx = state.sys.context;
|
||||
var settings = state.sys.settings;
|
||||
// var w = scene.sys.width;
|
||||
// var h = scene.sys.height;
|
||||
var ctx = scene.sys.context;
|
||||
var settings = scene.sys.settings;
|
||||
var scissor = (camera.x !== 0 || camera.y !== 0 || camera.width !== ctx.canvas.width || camera.height !== ctx.canvas.height);
|
||||
var list = children.list;
|
||||
|
||||
|
@ -211,8 +211,8 @@ var CanvasRenderer = new Class({
|
|||
child.renderCanvas(this, child, interpolationPercentage, camera);
|
||||
}
|
||||
|
||||
// Call the State.render function
|
||||
state.render.call(state, ctx, interpolationPercentage);
|
||||
// Call the Scene.render function
|
||||
scene.render.call(scene, ctx, interpolationPercentage);
|
||||
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
||||
|
||||
|
@ -238,10 +238,10 @@ var CanvasRenderer = new Class({
|
|||
}
|
||||
|
||||
// Blast it to the Game Canvas (if needed)
|
||||
if (settings.renderToTexture)
|
||||
{
|
||||
this.gameContext.drawImage(state.sys.canvas, 0, 0, w, h, settings.x, settings.y, w, h);
|
||||
}
|
||||
// if (settings.renderToTexture)
|
||||
// {
|
||||
// this.gameContext.drawImage(scene.sys.canvas, 0, 0, w, h, settings.x, settings.y, w, h);
|
||||
// }
|
||||
},
|
||||
|
||||
postRender: function ()
|
||||
|
|
|
@ -295,15 +295,15 @@ var WebGLRenderer = new Class({
|
|||
},
|
||||
|
||||
/**
|
||||
* Renders a single State.
|
||||
* Renders a single Scene.
|
||||
*
|
||||
* @method render
|
||||
* @param {Phaser.State} state - The State to be rendered.
|
||||
* @param {Phaser.Scene} scene - The Scene to be rendered.
|
||||
* @param {number} interpolationPercentage - The cumulative amount of time that hasn't been simulated yet, divided
|
||||
* by the amount of time that will be simulated the next time update()
|
||||
* runs. Useful for interpolating frames.
|
||||
*/
|
||||
render: function (state, children, interpolationPercentage, camera)
|
||||
render: function (scene, children, interpolationPercentage, camera)
|
||||
{
|
||||
var gl = this.gl;
|
||||
var quadBatch = this.quadBatch;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// These properties get injected into the State Factory Plugin
|
||||
// These properties get injected into the Scene Factory Plugin
|
||||
// The key is the factory reference, the value is the Game Object that is created
|
||||
// These can be modified via the config object
|
||||
|
|
@ -1,39 +1,39 @@
|
|||
var Components = require('./components/');
|
||||
var Class = require('../utils/Class');
|
||||
|
||||
var GlobalStateManager = new Class({
|
||||
var GlobalSceneManager = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
function GlobalStateManager (game, stateConfig)
|
||||
function GlobalSceneManager (game, sceneConfig)
|
||||
{
|
||||
this.game = game;
|
||||
|
||||
// Everything kept in here
|
||||
this.keys = {};
|
||||
this.states = [];
|
||||
this.scenes = [];
|
||||
|
||||
// Only active states are kept in here. They are moved here when started, and moved out when not.
|
||||
// All states are stored in the states array, regardless of being active or not.
|
||||
// Only active scenes are kept in here. They are moved here when started, and moved out when not.
|
||||
// All scenes are stored in the scenes array, regardless of being active or not.
|
||||
this.active = [];
|
||||
|
||||
// A state pending to be added to the State Manager is stored in here until the manager has time to add it.
|
||||
// A scene pending to be added to the Scene Manager is stored in here until the manager has time to add it.
|
||||
this._pending = [];
|
||||
|
||||
// An array of states waiting to be started once the game has booted
|
||||
// An array of scenes waiting to be started once the game has booted
|
||||
this._start = [];
|
||||
|
||||
if (stateConfig)
|
||||
if (sceneConfig)
|
||||
{
|
||||
if (Array.isArray(stateConfig))
|
||||
if (Array.isArray(sceneConfig))
|
||||
{
|
||||
for (var i = 0; i < stateConfig.length; i++)
|
||||
for (var i = 0; i < sceneConfig.length; i++)
|
||||
{
|
||||
// The i === 0 part just starts the first State given
|
||||
// The i === 0 part just starts the first Scene given
|
||||
this._pending.push({
|
||||
index: i,
|
||||
key: 'default',
|
||||
state: stateConfig[i],
|
||||
scene: sceneConfig[i],
|
||||
autoStart: (i === 0),
|
||||
data: {}
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ var GlobalStateManager = new Class({
|
|||
this._pending.push({
|
||||
index: 0,
|
||||
key: 'default',
|
||||
state: stateConfig,
|
||||
scene: sceneConfig,
|
||||
autoStart: true,
|
||||
data: {}
|
||||
});
|
||||
|
@ -54,21 +54,21 @@ var GlobalStateManager = new Class({
|
|||
|
||||
add: Components.Add,
|
||||
boot: Components.Boot,
|
||||
bootState: Components.BootState,
|
||||
bootScene: Components.BootScene,
|
||||
bringToTop: Components.BringToTop,
|
||||
create: Components.Create,
|
||||
createStateDisplay: Components.CreateStateDisplay,
|
||||
createStateFromFunction: Components.CreateStateFromFunction,
|
||||
createStateFromInstance: Components.CreateStateFromInstance,
|
||||
createStateFromObject: Components.CreateStateFromObject,
|
||||
getActiveState: Components.GetActiveState,
|
||||
getActiveStateIndex: Components.GetActiveStateIndex,
|
||||
getActiveStateIndexByKey: Components.GetActiveStateIndexByKey,
|
||||
createSceneDisplay: Components.CreateSceneDisplay,
|
||||
createSceneFromFunction: Components.CreateSceneFromFunction,
|
||||
createSceneFromInstance: Components.CreateSceneFromInstance,
|
||||
createSceneFromObject: Components.CreateSceneFromObject,
|
||||
getActiveScene: Components.GetActiveScene,
|
||||
getActiveSceneIndex: Components.GetActiveSceneIndex,
|
||||
getActiveSceneIndexByKey: Components.GetActiveSceneIndexByKey,
|
||||
getKey: Components.GetKey,
|
||||
getState: Components.GetState,
|
||||
getStateAt: Components.GetStateAt,
|
||||
getStateIndex: Components.GetStateIndex,
|
||||
getStateIndexByKey: Components.GetStateIndexByKey,
|
||||
getScene: Components.GetScene,
|
||||
getSceneAt: Components.GetSceneAt,
|
||||
getSceneIndex: Components.GetSceneIndex,
|
||||
getSceneIndexByKey: Components.GetSceneIndexByKey,
|
||||
isActive: Components.IsActive,
|
||||
isSleeping: Components.IsSleeping,
|
||||
loadComplete: Components.LoadComplete,
|
||||
|
@ -88,4 +88,4 @@ var GlobalStateManager = new Class({
|
|||
|
||||
});
|
||||
|
||||
module.exports = GlobalStateManager;
|
||||
module.exports = GlobalSceneManager;
|
|
@ -1,5 +1,5 @@
|
|||
// These properties get injected into the State and map to local systems
|
||||
// The key is the local system reference, the value is the property that is added to the State
|
||||
// These properties get injected into the Scene and map to local systems
|
||||
// The key is the local system reference, the value is the property that is added to the Scene
|
||||
// These can be modified via the config object
|
||||
|
||||
var InjectionMap = {
|
||||
|
@ -20,7 +20,7 @@ var InjectionMap = {
|
|||
load: 'load',
|
||||
make: 'make',
|
||||
pool: 'pool',
|
||||
stateManager: 'state',
|
||||
sceneManager: 'scene',
|
||||
time: 'time',
|
||||
tweens: 'tweens'
|
||||
|
|
@ -2,26 +2,26 @@
|
|||
var Class = require('../utils/Class');
|
||||
var Systems = require('./Systems');
|
||||
|
||||
var State = new Class({
|
||||
var Scene = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
function State (config)
|
||||
function Scene (config)
|
||||
{
|
||||
// The State Systems. You must never overwrite this property, or all hell will break lose.
|
||||
// The Scene Systems. You must never overwrite this property, or all hell will break lose.
|
||||
this.sys = new Systems(this, config);
|
||||
},
|
||||
|
||||
// Should be overridden by your own States
|
||||
// Should be overridden by your own Scenes
|
||||
update: function ()
|
||||
{
|
||||
},
|
||||
|
||||
// Should be overridden by your own States
|
||||
// Should be overridden by your own Scenes
|
||||
render: function ()
|
||||
{
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
module.exports = State;
|
||||
module.exports = Scene;
|
|
@ -37,11 +37,11 @@ var Settings = {
|
|||
|
||||
cameras: GetValue(config, 'cameras', null),
|
||||
|
||||
// State Property Injection Map
|
||||
// Scene Property Injection Map
|
||||
|
||||
map: GetValue(config, 'map', InjectionMap),
|
||||
|
||||
// State Render Settings (applies only to this State)
|
||||
// Scene Render Settings (applies only to this Scene)
|
||||
|
||||
scaleMode: GetValue(config, 'scaleMode', ScaleModes.DEFAULT),
|
||||
roundPixels: GetValue(config, 'roundPixels', false),
|
|
@ -12,7 +12,7 @@ var Loader = require('../plugins/Loader');
|
|||
var PoolManager = require('../plugins/PoolManager');
|
||||
var Settings = require('./Settings');
|
||||
var StableSort = require('../utils/array/StableSort');
|
||||
var StateManager = require('../plugins/StateManager');
|
||||
var SceneManager = require('../plugins/SceneManager');
|
||||
var TweenManager = require('../tween/TweenManager');
|
||||
var UpdateList = require('../plugins/UpdateList');
|
||||
|
||||
|
@ -20,16 +20,16 @@ var Systems = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function Systems (state, config)
|
||||
function Systems (scene, config)
|
||||
{
|
||||
this.state = state;
|
||||
this.scene = scene;
|
||||
|
||||
this.config = config;
|
||||
this.settings = Settings.create(config);
|
||||
|
||||
this.sortChildrenFlag = false;
|
||||
|
||||
// Set by the GlobalStateManager
|
||||
// Set by the GlobalSceneManager
|
||||
this.mask = null;
|
||||
this.canvas;
|
||||
this.context;
|
||||
|
@ -43,7 +43,7 @@ var Systems = new Class({
|
|||
this.registry;
|
||||
this.textures;
|
||||
|
||||
// Reference to State specific managers (Factory, Tweens, Loader, Physics, etc)
|
||||
// Reference to Scene specific managers (Factory, Tweens, Loader, Physics, etc)
|
||||
this.add;
|
||||
this.cameras;
|
||||
this.events;
|
||||
|
@ -51,11 +51,11 @@ var Systems = new Class({
|
|||
this.load;
|
||||
this.make;
|
||||
this.pool;
|
||||
this.stateManager;
|
||||
this.sceneManager;
|
||||
this.time;
|
||||
this.tweens;
|
||||
|
||||
// State properties
|
||||
// Scene properties
|
||||
this.updateList;
|
||||
this.displayList;
|
||||
this.data;
|
||||
|
@ -63,7 +63,7 @@ var Systems = new Class({
|
|||
|
||||
init: function (game)
|
||||
{
|
||||
var state = this.state;
|
||||
var scene = this.scene;
|
||||
|
||||
this.game = game;
|
||||
|
||||
|
@ -74,24 +74,24 @@ var Systems = new Class({
|
|||
this.registry = game.registry;
|
||||
this.textures = game.textures;
|
||||
|
||||
// State specific properties (transform, data, children, etc)
|
||||
// Scene specific properties (transform, data, children, etc)
|
||||
|
||||
this.inputManager = new InputManager(state, game);
|
||||
this.updateList = new UpdateList(state);
|
||||
this.displayList = new DisplayList(state);
|
||||
this.data = new Data(state);
|
||||
this.inputManager = new InputManager(scene, game);
|
||||
this.updateList = new UpdateList(scene);
|
||||
this.displayList = new DisplayList(scene);
|
||||
this.data = new Data(scene);
|
||||
|
||||
// State specific managers (Factory, Tweens, Loader, Physics, etc)
|
||||
// Scene specific managers (Factory, Tweens, Loader, Physics, etc)
|
||||
|
||||
this.add = new GameObjectFactory(state);
|
||||
this.cameras = new CameraManager(state);
|
||||
this.add = new GameObjectFactory(scene);
|
||||
this.cameras = new CameraManager(scene);
|
||||
this.events = new EventDispatcher();
|
||||
this.load = new Loader(state);
|
||||
this.make = new GameObjectCreator(state);
|
||||
this.pool = new PoolManager(state);
|
||||
this.stateManager = new StateManager(state, game);
|
||||
this.time = new Clock(state);
|
||||
this.tweens = new TweenManager(state);
|
||||
this.load = new Loader(scene);
|
||||
this.make = new GameObjectCreator(scene);
|
||||
this.pool = new PoolManager(scene);
|
||||
this.sceneManager = new SceneManager(scene, game);
|
||||
this.time = new Clock(scene);
|
||||
this.tweens = new TweenManager(scene);
|
||||
|
||||
// Sometimes the managers need access to a system created after them
|
||||
this.inputManager.boot();
|
||||
|
@ -110,14 +110,14 @@ var Systems = new Class({
|
|||
continue;
|
||||
}
|
||||
|
||||
this.state[map[key]] = this[key];
|
||||
this.scene[map[key]] = this[key];
|
||||
}
|
||||
},
|
||||
|
||||
step: function (time, delta)
|
||||
{
|
||||
// Are there any pending StateManager actions?
|
||||
this.stateManager.update();
|
||||
// Are there any pending SceneManager actions?
|
||||
this.sceneManager.update();
|
||||
|
||||
if (!this.settings.active)
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ var Systems = new Class({
|
|||
this.cameras.update(time, delta);
|
||||
this.inputManager.update(time, delta);
|
||||
|
||||
this.state.update.call(this.state, time, delta);
|
||||
this.scene.update.call(this.scene, time, delta);
|
||||
},
|
||||
|
||||
render: function (interpolation, renderer)
|
||||
|
@ -168,60 +168,60 @@ var Systems = new Class({
|
|||
return childA._z - childB._z;
|
||||
},
|
||||
|
||||
// A paused State still renders, it just doesn't run ANY of its update handlers or systems
|
||||
// A paused Scene still renders, it just doesn't run ANY of its update handlers or systems
|
||||
pause: function ()
|
||||
{
|
||||
// Was paused by the GlobalStateManager
|
||||
// Was paused by the GlobalSceneManager
|
||||
|
||||
this.settings.active = false;
|
||||
|
||||
if (this.state.pause)
|
||||
if (this.scene.pause)
|
||||
{
|
||||
this.state.pause.call(this.state);
|
||||
this.scene.pause.call(this.scene);
|
||||
}
|
||||
},
|
||||
|
||||
resume: function ()
|
||||
{
|
||||
// Was resumed by the GlobalStateManager
|
||||
// Was resumed by the GlobalSceneManager
|
||||
|
||||
this.settings.active = true;
|
||||
|
||||
if (this.state.resume)
|
||||
if (this.scene.resume)
|
||||
{
|
||||
this.state.resume.call(this.state);
|
||||
this.scene.resume.call(this.scene);
|
||||
}
|
||||
},
|
||||
|
||||
sleep: function ()
|
||||
{
|
||||
// Was sent to sleep by the GlobalStateManager
|
||||
// Was sent to sleep by the GlobalSceneManager
|
||||
|
||||
this.settings.active = false;
|
||||
this.settings.visible = false;
|
||||
|
||||
if (this.state.sleep)
|
||||
if (this.scene.sleep)
|
||||
{
|
||||
this.state.sleep.call(this.state);
|
||||
this.scene.sleep.call(this.scene);
|
||||
}
|
||||
},
|
||||
|
||||
wake: function ()
|
||||
{
|
||||
// Was woken up by the GlobalStateManager
|
||||
// Was woken up by the GlobalSceneManager
|
||||
|
||||
this.settings.active = true;
|
||||
this.settings.visible = true;
|
||||
|
||||
if (this.state.wake)
|
||||
if (this.scene.wake)
|
||||
{
|
||||
this.state.wake.call(this.state);
|
||||
this.scene.wake.call(this.scene);
|
||||
}
|
||||
},
|
||||
|
||||
start: function (data)
|
||||
{
|
||||
// Was started by the GlobalStateManager
|
||||
// Was started by the GlobalSceneManager
|
||||
|
||||
this.settings.data = data;
|
||||
|
||||
|
@ -231,7 +231,7 @@ var Systems = new Class({
|
|||
|
||||
shutdown: function ()
|
||||
{
|
||||
// Was stopped by the GlobalStateManager
|
||||
// Was stopped by the GlobalSceneManager
|
||||
|
||||
this.settings.active = false;
|
||||
this.settings.visible = false;
|
||||
|
@ -242,9 +242,9 @@ var Systems = new Class({
|
|||
this.time.shutdown();
|
||||
this.tweens.shutdown();
|
||||
|
||||
if (this.state.shutdown)
|
||||
if (this.scene.shutdown)
|
||||
{
|
||||
this.state.shutdown.call(this.state);
|
||||
this.scene.shutdown.call(this.scene);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -258,9 +258,9 @@ var Systems = new Class({
|
|||
this.tweens.destroy();
|
||||
|
||||
// etc
|
||||
if (this.state.destroy)
|
||||
if (this.scene.destroy)
|
||||
{
|
||||
this.state.destroy.call(this.state);
|
||||
this.scene.destroy.call(this.scene);
|
||||
}
|
||||
}
|
||||
|
89
v3/src/scene/components/Add.js
Normal file
89
v3/src/scene/components/Add.js
Normal file
|
@ -0,0 +1,89 @@
|
|||
var Scene = require('../Scene');
|
||||
|
||||
/**
|
||||
* Adds a new Scene into the GlobalSceneManager. You must give each Scene a unique key by which you'll identify it.
|
||||
* The Scene can be either a Phaser.Scene object (or an object that extends it), a plain JavaScript object or a function.
|
||||
* If a function is given a new scene object will be created by calling it.
|
||||
*
|
||||
* @method Phaser.GlobalSceneManager#add
|
||||
* @param {string} key - A unique key you use to reference this scene, i.e. "MainMenu", "Level1".
|
||||
* @param {Phaser.Scene|object|function} scene - The scene you want to switch to.
|
||||
* @param {boolean} [autoStart=false] - If true the Scene will be started immediately after adding it.
|
||||
*/
|
||||
var Add = function (key, sceneConfig, autoStart)
|
||||
{
|
||||
if (autoStart === undefined) { autoStart = false; }
|
||||
|
||||
// if not booted, then put scene into a holding pattern
|
||||
if (!this.game.isBooted)
|
||||
{
|
||||
this._pending.push({
|
||||
index: this._pending.length,
|
||||
key: key,
|
||||
scene: sceneConfig,
|
||||
autoStart: autoStart
|
||||
});
|
||||
|
||||
// console.log('GlobalSceneManager not yet booted, adding to list', this._pending.length);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// var ok = key;
|
||||
key = this.getKey(key, sceneConfig);
|
||||
|
||||
// console.group('GlobalSceneManager.add');
|
||||
// console.log('add key:', ok);
|
||||
// console.log('config key:', key);
|
||||
// console.log('config:', sceneConfig);
|
||||
// console.log('autoStart:', autoStart);
|
||||
// console.groupEnd();
|
||||
|
||||
var newScene;
|
||||
|
||||
if (sceneConfig instanceof Scene)
|
||||
{
|
||||
// console.log('GlobalSceneManager.add from instance:', key);
|
||||
|
||||
newScene = this.createSceneFromInstance(key, sceneConfig);
|
||||
}
|
||||
else if (typeof sceneConfig === 'object')
|
||||
{
|
||||
// console.log('GlobalSceneManager.add from object:', key);
|
||||
|
||||
sceneConfig.key = key;
|
||||
|
||||
newScene = this.createSceneFromObject(key, sceneConfig);
|
||||
}
|
||||
else if (typeof sceneConfig === 'function')
|
||||
{
|
||||
// console.log('GlobalSceneManager.add from function:', key);
|
||||
|
||||
newScene = this.createSceneFromFunction(key, sceneConfig);
|
||||
}
|
||||
|
||||
// Replace key in case the scene changed it
|
||||
key = newScene.sys.settings.key;
|
||||
|
||||
// console.log('replaced key', key);
|
||||
|
||||
this.keys[key] = newScene;
|
||||
|
||||
this.scenes.push(newScene);
|
||||
|
||||
if (autoStart || newScene.sys.settings.active)
|
||||
{
|
||||
if (this.game.isBooted)
|
||||
{
|
||||
this.start(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._start.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
return newScene;
|
||||
};
|
||||
|
||||
module.exports = Add;
|
|
@ -2,7 +2,7 @@
|
|||
* The Boot handler is called by Phaser.Game when it first starts up.
|
||||
* The renderer is available by now.
|
||||
*
|
||||
* @method Phaser.GlobalStateManager#boot
|
||||
* @method Phaser.GlobalSceneManager#boot
|
||||
* @private
|
||||
*/
|
||||
var Boot = function ()
|
||||
|
@ -14,7 +14,7 @@ var Boot = function ()
|
|||
{
|
||||
entry = this._pending[i];
|
||||
|
||||
this.add(entry.key, entry.state, entry.autoStart);
|
||||
this.add(entry.key, entry.scene, entry.autoStart);
|
||||
}
|
||||
|
||||
for (i = 0; i < this._start.length; i++)
|
|
@ -1,24 +1,24 @@
|
|||
var BootState = function (state)
|
||||
var BootScene = function (scene)
|
||||
{
|
||||
// console.log('bootState', state.sys.settings.key);
|
||||
// console.log('bootScene', scene.sys.settings.key);
|
||||
|
||||
if (state.init)
|
||||
if (scene.init)
|
||||
{
|
||||
state.init.call(state, state.sys.settings.data);
|
||||
scene.init.call(scene, scene.sys.settings.data);
|
||||
}
|
||||
|
||||
var loader = state.sys.load;
|
||||
var loader = scene.sys.load;
|
||||
|
||||
loader.reset();
|
||||
|
||||
if (state.preload)
|
||||
if (scene.preload)
|
||||
{
|
||||
state.preload(this.game);
|
||||
scene.preload(this.game);
|
||||
|
||||
// Is the loader empty?
|
||||
if (loader.list.size === 0)
|
||||
{
|
||||
this.create(state);
|
||||
this.create(scene);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -32,8 +32,8 @@ var BootState = function (state)
|
|||
else
|
||||
{
|
||||
// No preload? Then there was nothing to load either
|
||||
this.create(state);
|
||||
this.create(scene);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = BootState;
|
||||
module.exports = BootScene;
|
|
@ -1,9 +1,9 @@
|
|||
// If the arguments are strings they are assumed to be keys, otherwise they are State objects
|
||||
// You can only swap the positions of Active (rendering / updating) States. If a State is not active it cannot be moved.
|
||||
// If the arguments are strings they are assumed to be keys, otherwise they are Scene objects
|
||||
// You can only swap the positions of Active (rendering / updating) Scenes. If a Scene is not active it cannot be moved.
|
||||
|
||||
var BringToTop = function (state)
|
||||
var BringToTop = function (scene)
|
||||
{
|
||||
var index = (typeof state === 'string') ? this.getActiveStateIndexByKey(state) : this.getActiveStateIndex(state);
|
||||
var index = (typeof scene === 'string') ? this.getActiveSceneIndexByKey(scene) : this.getActiveSceneIndex(scene);
|
||||
|
||||
if (index < this.active.length)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ var BringToTop = function (state)
|
|||
this.active[i].index = i;
|
||||
}
|
||||
|
||||
this.active.push({ index: i, state: entry[0].state });
|
||||
this.active.push({ index: i, scene: entry[0].scene });
|
||||
}
|
||||
};
|
||||
|
25
v3/src/scene/components/Create.js
Normal file
25
v3/src/scene/components/Create.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
var SortScenes = require('./SortScenes');
|
||||
|
||||
var Create = function (scene)
|
||||
{
|
||||
// console.log('create', scene.sys.settings.key);
|
||||
// console.log(scene);
|
||||
|
||||
// Insert at the correct index, or it just all goes wrong :)
|
||||
|
||||
var i = this.getSceneIndex(scene);
|
||||
|
||||
// console.log('create.index', scene.sys.settings.key, i);
|
||||
|
||||
this.active.push({ index: i, scene: scene });
|
||||
|
||||
// Sort the 'active' array based on the index property
|
||||
this.active.sort(SortScenes);
|
||||
|
||||
if (scene.create)
|
||||
{
|
||||
scene.create.call(scene, scene.sys.settings.data);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Create;
|
|
@ -3,11 +3,11 @@ var CONST = require('../../const');
|
|||
var GetContext = require('../../canvas/GetContext');
|
||||
var CanvasInterpolation = require('../../dom/CanvasInterpolation');
|
||||
|
||||
var CreateStateDisplay = function (state)
|
||||
var CreateSceneDisplay = function (scene)
|
||||
{
|
||||
// console.log('createStateDisplay', state.sys.settings.key);
|
||||
// console.log('createSceneDisplay', scene.sys.settings.key);
|
||||
|
||||
var settings = state.sys.settings;
|
||||
var settings = scene.sys.settings;
|
||||
|
||||
var width = settings.width;
|
||||
var height = settings.height;
|
||||
|
@ -19,23 +19,23 @@ var CreateStateDisplay = function (state)
|
|||
if (settings.renderToTexture)
|
||||
{
|
||||
// console.log('renderToTexture', width, height);
|
||||
state.sys.canvas = CanvasPool.create(state, width, height);
|
||||
state.sys.context = GetContext(state.sys.canvas);
|
||||
scene.sys.canvas = CanvasPool.create(scene, width, height);
|
||||
scene.sys.context = GetContext(scene.sys.canvas);
|
||||
}
|
||||
else
|
||||
{
|
||||
// console.log('using game canvas');
|
||||
// state.sys.mask = new Rectangle(0, 0, width, height);
|
||||
state.sys.canvas = this.game.canvas;
|
||||
state.sys.context = this.game.context;
|
||||
// scene.sys.mask = new Rectangle(0, 0, width, height);
|
||||
scene.sys.canvas = this.game.canvas;
|
||||
scene.sys.context = this.game.context;
|
||||
}
|
||||
|
||||
// Pixel Art mode?
|
||||
if (config.pixelArt)
|
||||
{
|
||||
CanvasInterpolation.setCrisp(state.sys.canvas);
|
||||
CanvasInterpolation.setCrisp(scene.sys.canvas);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = CreateStateDisplay;
|
||||
module.exports = CreateSceneDisplay;
|
75
v3/src/scene/components/CreateSceneFromFunction.js
Normal file
75
v3/src/scene/components/CreateSceneFromFunction.js
Normal file
|
@ -0,0 +1,75 @@
|
|||
var Scene = require('../Scene');
|
||||
var Systems = require('../Systems');
|
||||
var NOOP = require('../../utils/NOOP');
|
||||
|
||||
var CreateSceneFromFunction = function (key, scene)
|
||||
{
|
||||
// console.log('createSceneFromFunction', key);
|
||||
|
||||
var newScene = new scene();
|
||||
|
||||
if (newScene instanceof Scene)
|
||||
{
|
||||
// console.log('instanceof Scene');
|
||||
|
||||
var configKey = newScene.sys.settings.key;
|
||||
|
||||
if (configKey !== '')
|
||||
{
|
||||
key = configKey;
|
||||
}
|
||||
|
||||
if (this.keys.hasOwnProperty(key))
|
||||
{
|
||||
throw new Error('Cannot add a Scene with duplicate key: ' + key);
|
||||
}
|
||||
|
||||
return this.createSceneFromInstance(key, newScene);
|
||||
}
|
||||
else
|
||||
{
|
||||
newScene.sys = new Systems(newScene);
|
||||
|
||||
newScene.sys.settings.key = key;
|
||||
|
||||
newScene.sys.init(this.game);
|
||||
|
||||
this.createSceneDisplay(newScene);
|
||||
|
||||
// Default required functions
|
||||
|
||||
if (!newScene.init)
|
||||
{
|
||||
newScene.init = NOOP;
|
||||
}
|
||||
|
||||
if (!newScene.preload)
|
||||
{
|
||||
newScene.preload = NOOP;
|
||||
}
|
||||
|
||||
if (!newScene.create)
|
||||
{
|
||||
newScene.create = NOOP;
|
||||
}
|
||||
|
||||
if (!newScene.shutdown)
|
||||
{
|
||||
newScene.shutdown = NOOP;
|
||||
}
|
||||
|
||||
if (!newScene.update)
|
||||
{
|
||||
newScene.update = NOOP;
|
||||
}
|
||||
|
||||
if (!newScene.render)
|
||||
{
|
||||
newScene.render = NOOP;
|
||||
}
|
||||
|
||||
return newScene;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = CreateSceneFromFunction;
|
21
v3/src/scene/components/CreateSceneFromInstance.js
Normal file
21
v3/src/scene/components/CreateSceneFromInstance.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
var CreateSceneFromInstance = function (key, newScene)
|
||||
{
|
||||
var configKey = newScene.sys.settings.key;
|
||||
|
||||
if (configKey !== '')
|
||||
{
|
||||
key = configKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
newScene.sys.settings.key = key;
|
||||
}
|
||||
|
||||
newScene.sys.init(this.game);
|
||||
|
||||
this.createSceneDisplay(newScene);
|
||||
|
||||
return newScene;
|
||||
};
|
||||
|
||||
module.exports = CreateSceneFromInstance;
|
25
v3/src/scene/components/CreateSceneFromObject.js
Normal file
25
v3/src/scene/components/CreateSceneFromObject.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
var Scene = require('../Scene');
|
||||
|
||||
var CreateSceneFromObject = function (key, sceneConfig)
|
||||
{
|
||||
var newScene = new Scene(sceneConfig);
|
||||
|
||||
var configKey = newScene.sys.settings.key;
|
||||
|
||||
if (configKey !== '')
|
||||
{
|
||||
key = configKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
newScene.sys.settings.key = key;
|
||||
}
|
||||
|
||||
newScene.sys.init(this.game);
|
||||
|
||||
this.createSceneDisplay(newScene);
|
||||
|
||||
return this.setupCallbacks(newScene, sceneConfig);
|
||||
};
|
||||
|
||||
module.exports = CreateSceneFromObject;
|
14
v3/src/scene/components/GetActiveScene.js
Normal file
14
v3/src/scene/components/GetActiveScene.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
var GetActiveScene = function (key)
|
||||
{
|
||||
var scene = this.getScene(key);
|
||||
|
||||
for (var i = 0; i < this.active.length; i++)
|
||||
{
|
||||
if (this.active[i].scene === scene)
|
||||
{
|
||||
return this.active[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = GetActiveScene;
|
|
@ -1,8 +1,8 @@
|
|||
var GetActiveStateIndex = function (state)
|
||||
var GetActiveSceneIndex = function (scene)
|
||||
{
|
||||
for (var i = 0; i < this.active.length; i++)
|
||||
{
|
||||
if (this.active[i].state === state)
|
||||
if (this.active[i].scene === scene)
|
||||
{
|
||||
return this.active[i].index;
|
||||
}
|
||||
|
@ -11,4 +11,4 @@ var GetActiveStateIndex = function (state)
|
|||
return -1;
|
||||
};
|
||||
|
||||
module.exports = GetActiveStateIndex;
|
||||
module.exports = GetActiveSceneIndex;
|
16
v3/src/scene/components/GetActiveSceneIndexByKey.js
Normal file
16
v3/src/scene/components/GetActiveSceneIndexByKey.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
var GetActiveSceneIndexByKey = function (key)
|
||||
{
|
||||
var scene = this.keys[key];
|
||||
|
||||
for (var i = 0; i < this.active.length; i++)
|
||||
{
|
||||
if (this.active[i].scene === scene)
|
||||
{
|
||||
return this.active[i].index;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
||||
module.exports = GetActiveSceneIndexByKey;
|
33
v3/src/scene/components/GetKey.js
Normal file
33
v3/src/scene/components/GetKey.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
var Scene = require('../Scene');
|
||||
|
||||
// private
|
||||
var GetKey = function (key, sceneConfig)
|
||||
{
|
||||
if (!key) { key = 'default'; }
|
||||
|
||||
if (typeof sceneConfig === 'function')
|
||||
{
|
||||
return key;
|
||||
}
|
||||
else if (sceneConfig instanceof Scene)
|
||||
{
|
||||
key = sceneConfig.sys.settings.key;
|
||||
}
|
||||
else if (typeof sceneConfig === 'object' && sceneConfig.hasOwnProperty('key'))
|
||||
{
|
||||
key = sceneConfig.key;
|
||||
}
|
||||
|
||||
// By this point it's either 'default' or extracted from the Scene
|
||||
|
||||
if (this.keys.hasOwnProperty(key))
|
||||
{
|
||||
throw new Error('Cannot add a Scene with duplicate key: ' + key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return key;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = GetKey;
|
6
v3/src/scene/components/GetScene.js
Normal file
6
v3/src/scene/components/GetScene.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
var GetScene = function (key)
|
||||
{
|
||||
return this.keys[key];
|
||||
};
|
||||
|
||||
module.exports = GetScene;
|
11
v3/src/scene/components/GetSceneAt.js
Normal file
11
v3/src/scene/components/GetSceneAt.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Get's the Active scene at the given position
|
||||
|
||||
var GetSceneAt = function (index)
|
||||
{
|
||||
if (this.active[index])
|
||||
{
|
||||
return this.active[index].scene;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = GetSceneAt;
|
6
v3/src/scene/components/GetSceneIndex.js
Normal file
6
v3/src/scene/components/GetSceneIndex.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
var GetSceneIndex = function (scene)
|
||||
{
|
||||
return this.scenes.indexOf(scene);
|
||||
};
|
||||
|
||||
module.exports = GetSceneIndex;
|
8
v3/src/scene/components/GetSceneIndexByKey.js
Normal file
8
v3/src/scene/components/GetSceneIndexByKey.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
var GetSceneIndexByKey = function (key)
|
||||
{
|
||||
var scene = this.keys[key];
|
||||
|
||||
return this.scenes.indexOf(scene);
|
||||
};
|
||||
|
||||
module.exports = GetSceneIndexByKey;
|
8
v3/src/scene/components/IsActive.js
Normal file
8
v3/src/scene/components/IsActive.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
var IsActive = function (key)
|
||||
{
|
||||
var scene = this.getScene(key);
|
||||
|
||||
return (scene && scene.sys.settings.active && this.active.indexOf(scene) !== -1);
|
||||
};
|
||||
|
||||
module.exports = IsActive;
|
|
@ -1,10 +1,10 @@
|
|||
var IsSleeping = function (key)
|
||||
{
|
||||
var entry = this.getActiveState(key);
|
||||
var entry = this.getActiveScene(key);
|
||||
|
||||
if (entry)
|
||||
{
|
||||
return (!entry.state.sys.settings.active && !entry.state.sys.settings.visible);
|
||||
return (!entry.scene.sys.settings.active && !entry.scene.sys.settings.visible);
|
||||
}
|
||||
|
||||
return false;
|
10
v3/src/scene/components/LoadComplete.js
Normal file
10
v3/src/scene/components/LoadComplete.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
var LoadComplete = function (event)
|
||||
{
|
||||
var scene = event.loader.scene;
|
||||
|
||||
// console.log('loadComplete', scene.sys.settings.key);
|
||||
|
||||
this.create(scene);
|
||||
};
|
||||
|
||||
module.exports = LoadComplete;
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue