mirror of
https://github.com/photonstorm/phaser
synced 2025-01-07 02:38:53 +00:00
Merge branch 'master' of https://github.com/photonstorm/phaser
This commit is contained in:
commit
b17744df61
9 changed files with 13 additions and 27 deletions
|
@ -17,7 +17,6 @@ var DynamicTilemapLayer = new Class({
|
||||||
Components.RenderTarget,
|
Components.RenderTarget,
|
||||||
Components.ScaleMode,
|
Components.ScaleMode,
|
||||||
Components.Size,
|
Components.Size,
|
||||||
Components.Texture,
|
|
||||||
Components.Transform,
|
Components.Transform,
|
||||||
Components.Visible,
|
Components.Visible,
|
||||||
Components.ScrollFactor,
|
Components.ScrollFactor,
|
||||||
|
@ -90,9 +89,7 @@ var DynamicTilemapLayer = new Class({
|
||||||
this.culledTiles = [];
|
this.culledTiles = [];
|
||||||
|
|
||||||
this.setAlpha(this.layer.alpha);
|
this.setAlpha(this.layer.alpha);
|
||||||
this.setTexture(tileset.image.key);
|
|
||||||
this.setPosition(x, y);
|
this.setPosition(x, y);
|
||||||
this.setSizeToFrame();
|
|
||||||
this.setOrigin();
|
this.setOrigin();
|
||||||
this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height);
|
this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height);
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,7 +11,7 @@ var DynamicTilemapLayerCanvasRenderer = function (renderer, gameObject, interpol
|
||||||
|
|
||||||
var renderTiles = gameObject.culledTiles;
|
var renderTiles = gameObject.culledTiles;
|
||||||
var length = renderTiles.length;
|
var length = renderTiles.length;
|
||||||
var image = gameObject.frame.source.image;
|
var image = gameObject.tileset.image.getSourceImage();
|
||||||
var tileset = this.tileset;
|
var tileset = this.tileset;
|
||||||
|
|
||||||
var tx = gameObject.x - camera.scrollX * gameObject.scrollFactorX;
|
var tx = gameObject.x - camera.scrollX * gameObject.scrollFactorX;
|
||||||
|
|
|
@ -12,7 +12,7 @@ var DynamicTilemapLayerWebGLRenderer = function (renderer, gameObject, interpola
|
||||||
var renderTiles = gameObject.culledTiles;
|
var renderTiles = gameObject.culledTiles;
|
||||||
var length = renderTiles.length;
|
var length = renderTiles.length;
|
||||||
var batch = renderer.spriteBatch;
|
var batch = renderer.spriteBatch;
|
||||||
var texture = gameObject.texture.source[0].glTexture;
|
var texture = gameObject.tileset.image.get().source.glTexture;
|
||||||
var textureWidth = texture.width;
|
var textureWidth = texture.width;
|
||||||
var textureHeight = texture.height;
|
var textureHeight = texture.height;
|
||||||
var tileset = this.tileset;
|
var tileset = this.tileset;
|
||||||
|
|
|
@ -18,7 +18,6 @@ var StaticTilemapLayer = new Class({
|
||||||
Components.RenderTarget,
|
Components.RenderTarget,
|
||||||
Components.ScaleMode,
|
Components.ScaleMode,
|
||||||
Components.Size,
|
Components.Size,
|
||||||
Components.Texture,
|
|
||||||
Components.Transform,
|
Components.Transform,
|
||||||
Components.Visible,
|
Components.Visible,
|
||||||
Components.ScrollFactor,
|
Components.ScrollFactor,
|
||||||
|
@ -99,9 +98,7 @@ var StaticTilemapLayer = new Class({
|
||||||
this.vertexCount = 0;
|
this.vertexCount = 0;
|
||||||
|
|
||||||
this.setAlpha(this.layer.alpha);
|
this.setAlpha(this.layer.alpha);
|
||||||
this.setTexture(tileset.image.key);
|
|
||||||
this.setPosition(x, y);
|
this.setPosition(x, y);
|
||||||
this.setSizeToFrame();
|
|
||||||
this.setOrigin();
|
this.setOrigin();
|
||||||
this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height);
|
this.setSize(this.layer.tileWidth * this.layer.width, this.layer.tileHeight * this.layer.height);
|
||||||
|
|
||||||
|
@ -113,7 +110,6 @@ var StaticTilemapLayer = new Class({
|
||||||
*/
|
*/
|
||||||
contextRestore: function (renderer)
|
contextRestore: function (renderer)
|
||||||
{
|
{
|
||||||
this.tileTexture = null;
|
|
||||||
this.dirty = true;
|
this.dirty = true;
|
||||||
this.vbo = null;
|
this.vbo = null;
|
||||||
this.gl = renderer.gl;
|
this.gl = renderer.gl;
|
||||||
|
@ -131,8 +127,8 @@ var StaticTilemapLayer = new Class({
|
||||||
var tileset = this.tileset;
|
var tileset = this.tileset;
|
||||||
var mapWidth = this.layer.width;
|
var mapWidth = this.layer.width;
|
||||||
var mapHeight = this.layer.height;
|
var mapHeight = this.layer.height;
|
||||||
var width = this.texture.source[0].width;
|
var width = tileset.image.get().width;
|
||||||
var height = this.texture.source[0].height;
|
var height = tileset.image.get().height;
|
||||||
var mapData = this.layer.data;
|
var mapData = this.layer.data;
|
||||||
|
|
||||||
var tile;
|
var tile;
|
||||||
|
|
|
@ -12,10 +12,9 @@ var StaticTilemapLayerCanvasRenderer = function (renderer, gameObject, interpola
|
||||||
|
|
||||||
var renderTiles = gameObject.culledTiles;
|
var renderTiles = gameObject.culledTiles;
|
||||||
var tileset = this.tileset;
|
var tileset = this.tileset;
|
||||||
var frame = gameObject.frame;
|
|
||||||
var ctx = renderer.gameContext;
|
var ctx = renderer.gameContext;
|
||||||
var tileCount = renderTiles.length;
|
var tileCount = renderTiles.length;
|
||||||
var image = frame.source.image;
|
var image = tileset.image.getSourceImage();
|
||||||
var tx = gameObject.x - camera.scrollX * gameObject.scrollFactorX;
|
var tx = gameObject.x - camera.scrollX * gameObject.scrollFactorX;
|
||||||
var ty = gameObject.y - camera.scrollY * gameObject.scrollFactorY;
|
var ty = gameObject.y - camera.scrollY * gameObject.scrollFactorY;
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPerc
|
||||||
}
|
}
|
||||||
|
|
||||||
var gameObject = src;
|
var gameObject = src;
|
||||||
var frame = gameObject.frame;
|
|
||||||
var gl = gameObject.gl;
|
var gl = gameObject.gl;
|
||||||
|
var frame = gameObject.tileset.image.get();
|
||||||
|
|
||||||
renderer.setRenderer(gameObject.tilemapRenderer, frame.texture.source[frame.sourceIndex].glTexture, gameObject.renderTarget);
|
renderer.setRenderer(gameObject.tilemapRenderer, frame.source.glTexture, gameObject.renderTarget);
|
||||||
|
|
||||||
gameObject.tilemapRenderer.bind();
|
gameObject.tilemapRenderer.bind();
|
||||||
gameObject.upload(camera);
|
gameObject.upload(camera);
|
||||||
|
|
|
@ -55,7 +55,7 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia
|
||||||
{
|
{
|
||||||
if (faceHorizontal)
|
if (faceHorizontal)
|
||||||
{
|
{
|
||||||
ox = TileCheckX(body, tile, tilemapLayer, tileBias);
|
ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias);
|
||||||
|
|
||||||
// That's horizontal done, check if we still intersects? If not then we can return now
|
// That's horizontal done, check if we still intersects? If not then we can return now
|
||||||
if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body))
|
if (ox !== 0 && !TileIntersectsBody(tileWorldRect, body))
|
||||||
|
@ -66,14 +66,14 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia
|
||||||
|
|
||||||
if (faceVertical)
|
if (faceVertical)
|
||||||
{
|
{
|
||||||
oy = TileCheckY(body, tile, tilemapLayer, tileBias);
|
oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (faceVertical)
|
if (faceVertical)
|
||||||
{
|
{
|
||||||
oy = TileCheckY(body, tile, tilemapLayer, tileBias);
|
oy = TileCheckY(body, tile, tileTop, tileBottom, tileBias);
|
||||||
|
|
||||||
// That's vertical done, check if we still intersects? If not then we can return now
|
// That's vertical done, check if we still intersects? If not then we can return now
|
||||||
if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body))
|
if (oy !== 0 && !TileIntersectsBody(tileWorldRect, body))
|
||||||
|
@ -84,7 +84,7 @@ var SeparateTile = function (i, body, tile, tileWorldRect, tilemapLayer, tileBia
|
||||||
|
|
||||||
if (faceHorizontal)
|
if (faceHorizontal)
|
||||||
{
|
{
|
||||||
ox = TileCheckX(body, tile, tilemapLayer, tileBias);
|
ox = TileCheckX(body, tile, tileLeft, tileRight, tileBias);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,12 +10,9 @@ var ProcessTileSeparationX = require('./ProcessTileSeparationX');
|
||||||
* @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against.
|
* @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against.
|
||||||
* @return {number} The amount of separation that occurred.
|
* @return {number} The amount of separation that occurred.
|
||||||
*/
|
*/
|
||||||
var TileCheckX = function (body, tile, tilemapLayer, tileBias)
|
var TileCheckX = function (body, tile, tileLeft, tileRight, tileBias)
|
||||||
{
|
{
|
||||||
var ox = 0;
|
var ox = 0;
|
||||||
var tileLeft = tilemapLayer.tileToWorldX(tile.x);
|
|
||||||
var tileWidth = tile.width * tilemapLayer.scaleX;
|
|
||||||
var tileRight = tileLeft + tileWidth;
|
|
||||||
|
|
||||||
if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left)
|
if (body.deltaX() < 0 && !body.blocked.left && tile.collideRight && body.checkCollision.left)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,12 +10,9 @@ var ProcessTileSeparationY = require('./ProcessTileSeparationY');
|
||||||
* @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against.
|
* @param {Phaser.TilemapLayer} tilemapLayer - The tilemapLayer to collide against.
|
||||||
* @return {number} The amount of separation that occurred.
|
* @return {number} The amount of separation that occurred.
|
||||||
*/
|
*/
|
||||||
var TileCheckY = function (body, tile, tilemapLayer, tileBias)
|
var TileCheckY = function (body, tile, tileTop, tileBottom, tileBias)
|
||||||
{
|
{
|
||||||
var oy = 0;
|
var oy = 0;
|
||||||
var tileTop = tilemapLayer.tileToWorldX(tile.y);
|
|
||||||
var tileHeight = tile.height * tilemapLayer.scaleY;
|
|
||||||
var tileBottom = tileTop + tileHeight;
|
|
||||||
|
|
||||||
if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up)
|
if (body.deltaY() < 0 && !body.blocked.up && tile.collideDown && body.checkCollision.up)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue