mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
camera scrolling
This commit is contained in:
parent
2c37dc3fda
commit
6f19416129
3 changed files with 7 additions and 6 deletions
|
@ -9,6 +9,8 @@ var Camera = function (x, y, width, height)
|
||||||
this.state = null;
|
this.state = null;
|
||||||
this.statePositionX = 0.0;
|
this.statePositionX = 0.0;
|
||||||
this.statePositionY = 0.0;
|
this.statePositionY = 0.0;
|
||||||
|
this.scrollX = 0.0;
|
||||||
|
this.scrollY = 0.0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Camera.prototype.setState = function (state)
|
Camera.prototype.setState = function (state)
|
||||||
|
@ -28,7 +30,7 @@ Camera.prototype.preRender = function (interpolation, renderer)
|
||||||
stateTransform.positionX = this.x;
|
stateTransform.positionX = this.x;
|
||||||
stateTransform.positionY = this.y;
|
stateTransform.positionY = this.y;
|
||||||
|
|
||||||
Transform.updateRoot(stateTransform);
|
Transform.updateRoot(stateTransform, -this.scrollX, -this.scrollY);
|
||||||
};
|
};
|
||||||
|
|
||||||
Camera.prototype.postRender = function ()
|
Camera.prototype.postRender = function ()
|
||||||
|
|
|
@ -72,7 +72,7 @@ Transform.prototype.remove = function (transform)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Transform.updateRoot = function (root)
|
Transform.updateRoot = function (root, globalOffsetX, globalOffsetY)
|
||||||
{
|
{
|
||||||
var currentChild = null;
|
var currentChild = null;
|
||||||
var stackLength = 0;
|
var stackLength = 0;
|
||||||
|
@ -117,8 +117,8 @@ Transform.updateRoot = function (root)
|
||||||
var p4 = tempLocal[4];
|
var p4 = tempLocal[4];
|
||||||
var p5 = tempLocal[5];
|
var p5 = tempLocal[5];
|
||||||
|
|
||||||
transX = child.positionX;
|
transX = child.positionX + globalOffsetX;
|
||||||
transY = child.positionY;
|
transY = child.positionY + globalOffsetY;
|
||||||
scaleX = child.scaleX;
|
scaleX = child.scaleX;
|
||||||
scaleY = child.scaleY;
|
scaleY = child.scaleY;
|
||||||
rotation = child.rotation;
|
rotation = child.rotation;
|
||||||
|
|
|
@ -273,7 +273,6 @@ WebGLRenderer.prototype = {
|
||||||
|
|
||||||
var list = state.sys.children.list;
|
var list = state.sys.children.list;
|
||||||
var length = list.length;
|
var length = list.length;
|
||||||
var matrixBuffer = Transform.float32Buffer;
|
|
||||||
for (var index = 0; index < length; ++index)
|
for (var index = 0; index < length; ++index)
|
||||||
{
|
{
|
||||||
var child = list[index];
|
var child = list[index];
|
||||||
|
@ -299,7 +298,7 @@ WebGLRenderer.prototype = {
|
||||||
this.blendMode = newBlendMode;
|
this.blendMode = newBlendMode;
|
||||||
}
|
}
|
||||||
// drawing child
|
// drawing child
|
||||||
child.renderWebGL(this, child, interpolationPercentage, matrixBuffer);
|
child.renderWebGL(this, child, interpolationPercentage);
|
||||||
batch = this.batch;
|
batch = this.batch;
|
||||||
if (batch && batch.isFull())
|
if (batch && batch.isFull())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue