mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 23:20:59 +00:00
Hooked up SpriteBatch.
This commit is contained in:
parent
f342fac027
commit
4ac4d406b2
5 changed files with 35 additions and 9 deletions
|
@ -37,7 +37,7 @@ var Game = function (config)
|
||||||
/**
|
/**
|
||||||
* @property {Phaser.TextureManager} textures - Reference to the Phaser Texture Manager.
|
* @property {Phaser.TextureManager} textures - Reference to the Phaser Texture Manager.
|
||||||
*/
|
*/
|
||||||
this.textures = new TextureManager();
|
this.textures = new TextureManager(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {Phaser.Cache} cache - Reference to the assets cache.
|
* @property {Phaser.Cache} cache - Reference to the assets cache.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
var CHECKSUM = {
|
var CHECKSUM = {
|
||||||
build: '98f0c510-de98-11e6-aa23-b3f509f20724'
|
build: '8e926790-de9d-11e6-bab6-b1cd883c1600'
|
||||||
};
|
};
|
||||||
module.exports = CHECKSUM;
|
module.exports = CHECKSUM;
|
|
@ -11,12 +11,22 @@ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var verts = src.transform.getVertexData(interpolationPercentage, renderer);
|
// var verts = src.transform.getVertexData(interpolationPercentage, renderer);
|
||||||
var index = src.frame.source.glTextureIndex;
|
// var index = src.frame.source.glTextureIndex;
|
||||||
var tint = src.color._glTint;
|
// var tint = src.color._glTint;
|
||||||
var bg = src.color._glBg;
|
// var bg = src.color._glBg;
|
||||||
|
// renderer.batch.add(frame.source, src.blendMode, verts, frame.uvs, index, alpha, tint, bg);
|
||||||
|
|
||||||
renderer.batch.add(frame.source, src.blendMode, verts, frame.uvs, index, alpha, tint, bg);
|
var transform = src.transform;
|
||||||
|
|
||||||
|
renderer.spriteBatch.add(
|
||||||
|
0, 0,
|
||||||
|
frame.cutWidth, frame.cutHeight,
|
||||||
|
0, 0, 1, 1,
|
||||||
|
transform.world.tx, transform.world.ty,
|
||||||
|
transform._worldScaleX, transform._worldScaleY,
|
||||||
|
transform._worldRotation
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ImageWebGLRenderer;
|
module.exports = ImageWebGLRenderer;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
var CONST = require('../../const');
|
var CONST = require('../../const');
|
||||||
var CreateEmptyTexture = require('./utils/CreateEmptyTexture');
|
var CreateEmptyTexture = require('./utils/CreateEmptyTexture');
|
||||||
|
var CreateTexture2DImage = require('./utils/texture/CreateTexture2DImage');
|
||||||
var BlitterBatch = require('./batches/blitter/BlitterBatch');
|
var BlitterBatch = require('./batches/blitter/BlitterBatch');
|
||||||
var SpriteBatch = require('./batches/sprite/SpriteBatch');
|
var SpriteBatch = require('./batches/sprite/SpriteBatch');
|
||||||
|
|
||||||
|
@ -46,8 +47,10 @@ var WebGLRenderer = function (game)
|
||||||
this.gl = null;
|
this.gl = null;
|
||||||
|
|
||||||
this.init();
|
this.init();
|
||||||
|
|
||||||
this.blitterBatch = new BlitterBatch(game, this.gl, this);
|
this.blitterBatch = new BlitterBatch(game, this.gl, this);
|
||||||
this.spriteBatch = new SpriteBatch(game, this.gl, this);
|
this.spriteBatch = new SpriteBatch(game, this.gl, this);
|
||||||
|
|
||||||
this.batch = null;
|
this.batch = null;
|
||||||
this.currentTexture2D = null;
|
this.currentTexture2D = null;
|
||||||
};
|
};
|
||||||
|
@ -133,6 +136,18 @@ WebGLRenderer.prototype = {
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
createTexture2D: function (source)
|
||||||
|
{
|
||||||
|
var gl = this.gl;
|
||||||
|
|
||||||
|
if (!source.glTexture)
|
||||||
|
{
|
||||||
|
source.glTexture = CreateTexture2DImage(gl, source.image, gl.NEAREST, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.currentTexture2D = source.glTexture;
|
||||||
|
},
|
||||||
|
|
||||||
setTexture2D: function (texture2D)
|
setTexture2D: function (texture2D)
|
||||||
{
|
{
|
||||||
this.currentTexture = texture2D;
|
this.currentTexture = texture2D;
|
||||||
|
|
|
@ -18,8 +18,10 @@ var Texture = require('./Texture');
|
||||||
* @class Phaser.TextureManager
|
* @class Phaser.TextureManager
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
var TextureManager = function ()
|
var TextureManager = function (game)
|
||||||
{
|
{
|
||||||
|
this.game = game;
|
||||||
|
|
||||||
this.list = {};
|
this.list = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -169,7 +171,6 @@ TextureManager.prototype = {
|
||||||
this.list[key] = texture;
|
this.list[key] = texture;
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
exists: function (key)
|
exists: function (key)
|
||||||
|
|
Loading…
Reference in a new issue