Skip to content

Commit 4ac4d40

Browse files
committed
Hooked up SpriteBatch.
1 parent f342fac commit 4ac4d40

5 files changed

Lines changed: 35 additions & 9 deletions

File tree

v3/src/boot/Game.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var Game = function (config)
3737
/**
3838
* @property {Phaser.TextureManager} textures - Reference to the Phaser Texture Manager.
3939
*/
40-
this.textures = new TextureManager();
40+
this.textures = new TextureManager(this);
4141

4242
/**
4343
* @property {Phaser.Cache} cache - Reference to the assets cache.

v3/src/checksum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
var CHECKSUM = {
2-
build: '98f0c510-de98-11e6-aa23-b3f509f20724'
2+
build: '8e926790-de9d-11e6-bab6-b1cd883c1600'
33
};
44
module.exports = CHECKSUM;

v3/src/gameobjects/image/ImageWebGLRenderer.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,22 @@ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage)
1111
return;
1212
}
1313

14-
var verts = src.transform.getVertexData(interpolationPercentage, renderer);
15-
var index = src.frame.source.glTextureIndex;
16-
var tint = src.color._glTint;
17-
var bg = src.color._glBg;
14+
// var verts = src.transform.getVertexData(interpolationPercentage, renderer);
15+
// var index = src.frame.source.glTextureIndex;
16+
// var tint = src.color._glTint;
17+
// var bg = src.color._glBg;
18+
// renderer.batch.add(frame.source, src.blendMode, verts, frame.uvs, index, alpha, tint, bg);
1819

19-
renderer.batch.add(frame.source, src.blendMode, verts, frame.uvs, index, alpha, tint, bg);
20+
var transform = src.transform;
21+
22+
renderer.spriteBatch.add(
23+
0, 0,
24+
frame.cutWidth, frame.cutHeight,
25+
0, 0, 1, 1,
26+
transform.world.tx, transform.world.ty,
27+
transform._worldScaleX, transform._worldScaleY,
28+
transform._worldRotation
29+
);
2030
};
2131

2232
module.exports = ImageWebGLRenderer;

v3/src/renderer/webgl/WebGLRenderer.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
var CONST = require('../../const');
99
var CreateEmptyTexture = require('./utils/CreateEmptyTexture');
10+
var CreateTexture2DImage = require('./utils/texture/CreateTexture2DImage');
1011
var BlitterBatch = require('./batches/blitter/BlitterBatch');
1112
var SpriteBatch = require('./batches/sprite/SpriteBatch');
1213

@@ -46,8 +47,10 @@ var WebGLRenderer = function (game)
4647
this.gl = null;
4748

4849
this.init();
50+
4951
this.blitterBatch = new BlitterBatch(game, this.gl, this);
5052
this.spriteBatch = new SpriteBatch(game, this.gl, this);
53+
5154
this.batch = null;
5255
this.currentTexture2D = null;
5356
};
@@ -133,6 +136,18 @@ WebGLRenderer.prototype = {
133136
];
134137
},
135138

139+
createTexture2D: function (source)
140+
{
141+
var gl = this.gl;
142+
143+
if (!source.glTexture)
144+
{
145+
source.glTexture = CreateTexture2DImage(gl, source.image, gl.NEAREST, 0);
146+
}
147+
148+
this.currentTexture2D = source.glTexture;
149+
},
150+
136151
setTexture2D: function (texture2D)
137152
{
138153
this.currentTexture = texture2D;

v3/src/textures/TextureManager.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ var Texture = require('./Texture');
1818
* @class Phaser.TextureManager
1919
* @constructor
2020
*/
21-
var TextureManager = function ()
21+
var TextureManager = function (game)
2222
{
23+
this.game = game;
24+
2325
this.list = {};
2426
};
2527

@@ -169,7 +171,6 @@ TextureManager.prototype = {
169171
this.list[key] = texture;
170172

171173
return texture;
172-
173174
},
174175

175176
exists: function (key)

0 commit comments

Comments
 (0)