mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 06:28:30 +00:00
Enforced GameObjects to specify their type (a string based const)
This commit is contained in:
parent
612db78818
commit
929d6fc8ef
11 changed files with 47 additions and 20 deletions
|
@ -16,11 +16,12 @@ var GameObject = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function GameObject (state)
|
||||
function GameObject (state, type)
|
||||
{
|
||||
this.state = state;
|
||||
|
||||
this.id = 0;
|
||||
this.type = type;
|
||||
this.name = '';
|
||||
|
||||
this.parent;
|
||||
|
|
|
@ -28,7 +28,7 @@ var DynamicBitmapText = new Class({
|
|||
if (size === undefined) { size = 32; }
|
||||
if (align === undefined) { align = 'left'; }
|
||||
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'DynamicBitmapText');
|
||||
|
||||
this.fontData = this.state.sys.cache.bitmapFont.get(font);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ var BitmapText = new Class({
|
|||
if (size === undefined) { size = 32; }
|
||||
if (align === undefined) { align = 'left'; }
|
||||
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'BitmapText');
|
||||
|
||||
this.fontData = this.state.sys.cache.bitmapFont.get(font);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ var Blitter = new Class({
|
|||
|
||||
function Blitter (state, x, y, texture, frame)
|
||||
{
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'Blitter');
|
||||
|
||||
this.setTexture(texture, frame);
|
||||
this.setPosition(x, y);
|
||||
|
|
|
@ -24,14 +24,14 @@ var EffectLayer = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function EffectLayer(state, x, y, width, height, effectName, fragmentShader)
|
||||
function EffectLayer (state, x, y, width, height, effectName, fragmentShader)
|
||||
{
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'EffectLayer');
|
||||
|
||||
var resourceManager = state.game.renderer.resourceManager;
|
||||
var gl;
|
||||
|
||||
this.dstRenderTarget = null
|
||||
this.dstRenderTarget = null;
|
||||
this.dstRenderTexture = null;
|
||||
this.dstShader = null;
|
||||
this.uniforms = {};
|
||||
|
@ -39,20 +39,24 @@ var EffectLayer = new Class({
|
|||
if (resourceManager !== undefined)
|
||||
{
|
||||
gl = state.game.renderer.gl;
|
||||
|
||||
this.dstShader = resourceManager.createShader(effectName, {
|
||||
vert: TexturedAndNormalizedTintedShader.vert,
|
||||
frag: fragmentShader
|
||||
});
|
||||
|
||||
this.dstRenderTexture = resourceManager.createTexture(
|
||||
0,
|
||||
gl.LINEAR, gl.LINEAR,
|
||||
gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE,
|
||||
gl.RGBA,
|
||||
0,
|
||||
gl.LINEAR, gl.LINEAR,
|
||||
gl.CLAMP_TO_EDGE, gl.CLAMP_TO_EDGE,
|
||||
gl.RGBA,
|
||||
null, width, height
|
||||
);
|
||||
this.dstRenderTarget = resourceManager.createRenderTarget(width, height, this.dstRenderTexture, null);
|
||||
|
||||
this.dstRenderTarget = resourceManager.createRenderTarget(width, height, this.dstRenderTexture, null);
|
||||
//state.game.renderer.currentTexture = null; // force rebinding of prev texture
|
||||
}
|
||||
|
||||
this.flipY = true;
|
||||
this.setPosition(x, y);
|
||||
this.setSize(width, height);
|
||||
|
@ -72,7 +76,7 @@ var EffectLayer = new Class({
|
|||
if (gameObject.renderTarget !== undefined)
|
||||
{
|
||||
gameObject.renderTarget = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getUniformLocation: function (uniformName)
|
||||
|
@ -99,7 +103,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantFloat1(this.getUniformLocation(uniformName), x);
|
||||
},
|
||||
|
@ -109,7 +115,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantFloat2(this.getUniformLocation(uniformName), x, y);
|
||||
},
|
||||
|
@ -119,7 +127,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantFloat3(this.getUniformLocation(uniformName), x, y, z);
|
||||
},
|
||||
|
@ -129,7 +139,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantFloat4(this.getUniformLocation(uniformName), x, y, z, w);
|
||||
},
|
||||
|
@ -139,7 +151,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantInt1(this.getUniformLocation(uniformName), x);
|
||||
},
|
||||
|
@ -149,7 +163,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantInt2(this.getUniformLocation(uniformName), x, y);
|
||||
},
|
||||
|
@ -159,7 +175,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantInt3(this.getUniformLocation(uniformName), x, y, z);
|
||||
},
|
||||
|
@ -169,7 +187,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantInt4(this.getUniformLocation(uniformName), x, y, z, w);
|
||||
},
|
||||
|
@ -179,7 +199,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantMatrix2x2(this.getUniformLocation(uniformName), matrix);
|
||||
},
|
||||
|
@ -189,7 +211,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantMatrix3x3(this.getUniformLocation(uniformName), matrix);
|
||||
},
|
||||
|
@ -199,7 +223,9 @@ var EffectLayer = new Class({
|
|||
var dstShader = this.dstShader;
|
||||
|
||||
if (dstShader === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
dstShader.setConstantMatrix4x4(this.getUniformLocation(uniformName), matrix);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ var Graphics = new Class({
|
|||
var x = GetObjectValue(options, 'x', 0);
|
||||
var y = GetObjectValue(options, 'y', 0);
|
||||
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'Graphics');
|
||||
|
||||
this.setPosition(x, y);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ var Image = new Class({
|
|||
|
||||
function Image (state, x, y, texture, frame)
|
||||
{
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'Image');
|
||||
|
||||
this.setTexture(texture, frame);
|
||||
this.setPosition(x, y);
|
||||
|
|
|
@ -23,9 +23,9 @@ var RenderPass = new Class({
|
|||
|
||||
initialize:
|
||||
|
||||
function RenderPass(state, x, y, width, height, shaderName, fragmentShader)
|
||||
function RenderPass (state, x, y, width, height, shaderName, fragmentShader)
|
||||
{
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'RenderPass');
|
||||
|
||||
var resourceManager = state.game.renderer.resourceManager;
|
||||
var gl;
|
||||
|
|
|
@ -27,7 +27,7 @@ var Sprite = new Class({
|
|||
|
||||
function Sprite (state, x, y, texture, frame)
|
||||
{
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'Sprite');
|
||||
|
||||
this.anims = new Components.Animation(this);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ var Text = new Class({
|
|||
if (y === undefined) { y = 0; }
|
||||
if (text === undefined) { text = ''; }
|
||||
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'Text');
|
||||
|
||||
this.setPosition(x, y);
|
||||
this.setOrigin(0, 0);
|
||||
|
|
|
@ -20,7 +20,7 @@ var Zone = new Class({
|
|||
|
||||
function Zone (state, x, y, width, height)
|
||||
{
|
||||
GameObject.call(this, state);
|
||||
GameObject.call(this, state, 'Zone');
|
||||
|
||||
this.setPosition(x, y);
|
||||
this.setSize(width, height);
|
||||
|
|
Loading…
Add table
Reference in a new issue