mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Anchoring support on SpriteBatch
This commit is contained in:
parent
5e1e495240
commit
bf9022bbe0
4 changed files with 10 additions and 11 deletions
|
@ -21,7 +21,7 @@ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage)
|
|||
|
||||
renderer.spriteBatch.add(
|
||||
frame,
|
||||
transform._pivotX, transform._pivotY,
|
||||
transform._anchorX, transform._anchorY,
|
||||
transform.world.tx, transform.world.ty,
|
||||
transform._worldScaleX, transform._worldScaleY,
|
||||
transform._worldRotation,
|
||||
|
|
|
@ -133,7 +133,7 @@ SpriteBatch.prototype = {
|
|||
return (this.vertexDataBuffer.getByteLength() >= this.vertexDataBuffer.getByteCapacity());
|
||||
},
|
||||
|
||||
add: function (frame, pivotX, pivotY, translateX, translateY, scaleX, scaleY, rotation, vertexColor)
|
||||
add: function (frame, anchorX, anchorY, translateX, translateY, scaleX, scaleY, rotation, vertexColor)
|
||||
{
|
||||
this.manager.setBatch(this, frame.texture.source[0].glTexture);
|
||||
|
||||
|
@ -144,10 +144,10 @@ SpriteBatch.prototype = {
|
|||
var vertexBufferU32 = vertexDataBuffer.uintView;
|
||||
var vertexOffset = vertexDataBuffer.allocate(CONST.SPRITE_VERTEX_COMPONENT_COUNT * CONST.SPRITE_VERTEX_COUNT);
|
||||
var uvs = frame.uvs;
|
||||
var x = -pivotX;
|
||||
var y = -pivotY;
|
||||
var width = frame.width;
|
||||
var height = frame.height;
|
||||
var x = width * -anchorX;
|
||||
var y = height * -anchorY;
|
||||
|
||||
vertexBufferF32[vertexOffset++] = x;
|
||||
vertexBufferF32[vertexOffset++] = y;
|
||||
|
|
|
@ -137,7 +137,7 @@ SpriteBatch32.prototype = {
|
|||
return (this.vertexDataBuffer.getByteLength() >= this.vertexDataBuffer.getByteCapacity());
|
||||
},
|
||||
|
||||
add: function (frame, pivotX, pivotY, translateX, translateY, scaleX, scaleY, rotation, vertexColor)
|
||||
add: function (frame, anchorX, anchorY, translateX, translateY, scaleX, scaleY, rotation, vertexColor)
|
||||
{
|
||||
this.manager.setBatch(this, frame.texture.source[0].glTexture);
|
||||
|
||||
|
@ -148,11 +148,11 @@ SpriteBatch32.prototype = {
|
|||
var vertexBufferU32 = vertexDataBuffer.uintView;
|
||||
var vertexOffset = vertexDataBuffer.allocate(CONST.SPRITE_VERTEX_COMPONENT_COUNT * CONST.SPRITE_VERTEX_COUNT);
|
||||
var uvs = frame.uvs;
|
||||
var x = -pivotX;
|
||||
var y = -pivotY;
|
||||
var width = frame.width;
|
||||
var height = frame.height;
|
||||
|
||||
var x = width * -anchorX;
|
||||
var y = height * -anchorY;
|
||||
|
||||
vertexBufferF32[vertexOffset++] = x;
|
||||
vertexBufferF32[vertexOffset++] = y;
|
||||
vertexBufferF32[vertexOffset++] = uvs.x0;
|
||||
|
|
|
@ -11,10 +11,9 @@ module.exports = [
|
|||
'void main () {',
|
||||
' float t_cos = cos(a_rotation);',
|
||||
' float t_sin = sin(a_rotation);',
|
||||
' vec2 t_position = a_position * a_scale;',
|
||||
' vec2 t_position = (a_position );',
|
||||
' t_position = vec2(t_position.x * t_cos - t_position.y * t_sin, t_position.x * t_sin + t_position.y * t_cos);',
|
||||
' t_position += a_translate;',
|
||||
' gl_Position = u_view_matrix * vec4(t_position, 1.0, 1.0);',
|
||||
' gl_Position = u_view_matrix * vec4((t_position * a_scale) + a_translate, 1.0, 1.0);',
|
||||
' v_tex_coord = a_tex_coord;',
|
||||
' v_color = a_color;',
|
||||
'}'
|
||||
|
|
Loading…
Reference in a new issue