mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Renderers now using the Origin property.
This commit is contained in:
parent
91bb3c8a98
commit
98eb2e3155
5 changed files with 19 additions and 14 deletions
|
@ -10,6 +10,7 @@ var Image = new Class({
|
|||
Components.Alpha,
|
||||
Components.BlendMode,
|
||||
Components.GetBounds,
|
||||
Components.Origin,
|
||||
Components.ScaleMode,
|
||||
Components.Size,
|
||||
Components.Texture,
|
||||
|
@ -26,6 +27,7 @@ var Image = new Class({
|
|||
|
||||
this.setTexture(texture, frame);
|
||||
this.setPosition(x, y);
|
||||
this.setOriginToCenter();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -13,8 +13,8 @@ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camer
|
|||
var frame = src.frame;
|
||||
var alpha = 16777216;
|
||||
var spriteBatch = renderer.spriteBatch;
|
||||
var anchorX = src.anchorX;
|
||||
var anchorY = src.anchorY;
|
||||
// var anchorX = src.anchorX;
|
||||
// var anchorY = src.anchorY;
|
||||
//var vertexColor = src.color._glTint;
|
||||
var vertexDataBuffer = spriteBatch.vertexDataBuffer;
|
||||
var vertexBufferF32 = vertexDataBuffer.floatView;
|
||||
|
@ -35,8 +35,8 @@ var ImageWebGLRenderer = function (renderer, src, interpolationPercentage, camer
|
|||
var d = cameraMatrix[3];
|
||||
var e = cameraMatrix[4];
|
||||
var f = cameraMatrix[5];
|
||||
var x = width * -anchorX + frame.x;
|
||||
var y = height * -anchorY + frame.y;
|
||||
var x = -src.originX + frame.x;
|
||||
var y = -src.originY + frame.y;
|
||||
var xw = x + width;
|
||||
var yh = y + height;
|
||||
var tx = x * a + y * c + e;
|
||||
|
|
|
@ -7,12 +7,14 @@ var SpriteRender = require('./SpriteRender');
|
|||
var Sprite = new Class({
|
||||
|
||||
Mixins: [
|
||||
Components.Transform,
|
||||
Components.Texture,
|
||||
Components.Size,
|
||||
Components.Alpha,
|
||||
Components.BlendMode,
|
||||
Components.GetBounds,
|
||||
Components.Origin,
|
||||
Components.ScaleMode,
|
||||
Components.Size,
|
||||
Components.Texture,
|
||||
Components.Transform,
|
||||
Components.Visible,
|
||||
SpriteRender
|
||||
],
|
||||
|
@ -23,8 +25,9 @@ var Sprite = new Class({
|
|||
{
|
||||
GameObject.call(this, state);
|
||||
|
||||
this.setPosition(x, y);
|
||||
this.setTexture(texture, frame);
|
||||
this.setPosition(x, y);
|
||||
this.setOriginToCenter();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -13,8 +13,8 @@ var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, came
|
|||
var frame = src.frame;
|
||||
var alpha = 16777216;
|
||||
var spriteBatch = renderer.spriteBatch;
|
||||
var anchorX = src.anchorX;
|
||||
var anchorY = src.anchorY;
|
||||
// var anchorX = src.anchorX;
|
||||
// var anchorY = src.anchorY;
|
||||
//var vertexColor = src.color._glTint;
|
||||
var vertexDataBuffer = spriteBatch.vertexDataBuffer;
|
||||
var vertexBufferF32 = vertexDataBuffer.floatView;
|
||||
|
@ -35,8 +35,8 @@ var SpriteWebGLRenderer = function (renderer, src, interpolationPercentage, came
|
|||
var d = cameraMatrix[3];
|
||||
var e = cameraMatrix[4];
|
||||
var f = cameraMatrix[5];
|
||||
var x = width * -anchorX + frame.x;
|
||||
var y = height * -anchorY + frame.y;
|
||||
var x = -src.originX + frame.x;
|
||||
var y = -src.originY + frame.y;
|
||||
var xw = x + width;
|
||||
var yh = y + height;
|
||||
var tx = x * a + y * c + e;
|
||||
|
|
|
@ -29,8 +29,8 @@ var DrawImage = function (src, camera)
|
|||
// ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR);
|
||||
}
|
||||
|
||||
var dx = frame.x - (src.anchorX * frame.width) - camera.scrollX;
|
||||
var dy = frame.y - (src.anchorY * frame.height) - camera.scrollY;
|
||||
var dx = frame.x - src.originX - camera.scrollX;
|
||||
var dy = frame.y - src.originY - camera.scrollY;
|
||||
|
||||
ctx.save();
|
||||
ctx.translate(src.x, src.y);
|
||||
|
|
Loading…
Reference in a new issue