mirror of
https://github.com/photonstorm/phaser
synced 2025-02-18 15:08:31 +00:00
Merge branch 'master' of https://github.com/photonstorm/phaser
This commit is contained in:
commit
779a156be9
4 changed files with 17 additions and 12 deletions
|
@ -15,8 +15,9 @@ var BuildFromConfig = function (state, config)
|
||||||
var tileHeight = GetValue(config, 'tile.height', 16);
|
var tileHeight = GetValue(config, 'tile.height', 16);
|
||||||
var tileTexture = GetValue(config, 'tile.texture', null);
|
var tileTexture = GetValue(config, 'tile.texture', null);
|
||||||
var tileFrame = GetValue(config, 'tile.frame', null);
|
var tileFrame = GetValue(config, 'tile.frame', null);
|
||||||
|
var tileBorder = GetValue(config, 'tile.border', 0);
|
||||||
|
|
||||||
var map = new StaticTilemap(state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileTexture, tileFrame);
|
var map = new StaticTilemap(state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, tileTexture, tileFrame);
|
||||||
|
|
||||||
BuildGameObject(state, map, config);
|
BuildGameObject(state, map, config);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ var StaticTilemap = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
|
||||||
function StaticTilemap (state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, texture, frame)
|
function StaticTilemap (state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||||
{
|
{
|
||||||
GameObject.call(this, state, 'StaticTilemap');
|
GameObject.call(this, state, 'StaticTilemap');
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ var StaticTilemap = new Class({
|
||||||
this.vertexCount = 0;
|
this.vertexCount = 0;
|
||||||
this.cullStart = 0;
|
this.cullStart = 0;
|
||||||
this.cullEnd = 0;
|
this.cullEnd = 0;
|
||||||
|
this.tileBorder = tileBorder;
|
||||||
this.setTexture(texture, frame);
|
this.setTexture(texture, frame);
|
||||||
this.setPosition(x, y);
|
this.setPosition(x, y);
|
||||||
this.setSizeToFrame();
|
this.setSizeToFrame();
|
||||||
|
@ -62,8 +63,11 @@ var StaticTilemap = new Class({
|
||||||
var vbo = this.vbo;
|
var vbo = this.vbo;
|
||||||
var mapWidth = this.mapWidth;
|
var mapWidth = this.mapWidth;
|
||||||
var mapHeight = this.mapHeight;
|
var mapHeight = this.mapHeight;
|
||||||
|
var border = this.tileBorder;
|
||||||
var tileWidth = this.tileWidth;
|
var tileWidth = this.tileWidth;
|
||||||
var tileHeight = this.tileHeight;
|
var tileHeight = this.tileHeight;
|
||||||
|
var tileWidthBorder = tileWidth + border * 2;
|
||||||
|
var tileHeightBorder = tileHeight + border * 2;
|
||||||
var bufferData = this.bufferData;
|
var bufferData = this.bufferData;
|
||||||
var bufferF32, bufferU32;
|
var bufferF32, bufferU32;
|
||||||
var voffset = 0;
|
var voffset = 0;
|
||||||
|
@ -89,10 +93,10 @@ var StaticTilemap = new Class({
|
||||||
for (var x = 0; x < mapWidth; ++x)
|
for (var x = 0; x < mapWidth; ++x)
|
||||||
{
|
{
|
||||||
var tileId = mapData[y * mapWidth + x];
|
var tileId = mapData[y * mapWidth + x];
|
||||||
var halfTileWidth = (tileWidth) * 0.5;
|
var halfTileWidth = (tileWidthBorder) * 0.5;
|
||||||
var halfTileHeight = (tileHeight) * 0.5;
|
var halfTileHeight = (tileHeightBorder) * 0.5;
|
||||||
var rectx = (((tileId % setWidth)|0) * tileWidth) + halfTileWidth;
|
var rectx = (((tileId % setWidth)|0) * tileWidthBorder) + halfTileWidth;
|
||||||
var recty = (((tileId / setWidth)|0) * tileHeight) + halfTileHeight;
|
var recty = (((tileId / setWidth)|0) * tileHeightBorder) + halfTileHeight;
|
||||||
var tx = x * tileWidth;
|
var tx = x * tileWidth;
|
||||||
var ty = y * tileHeight;
|
var ty = y * tileHeight;
|
||||||
var txw = tx + tileWidth;
|
var txw = tx + tileWidth;
|
||||||
|
|
|
@ -7,9 +7,9 @@ var StaticTilemapFactory = {
|
||||||
|
|
||||||
KEY: 'staticTilemap',
|
KEY: 'staticTilemap',
|
||||||
|
|
||||||
add: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, texture, frame)
|
add: function (mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame)
|
||||||
{
|
{
|
||||||
return this.children.add(new StaticTilemap(this.state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, texture, frame));
|
return this.children.add(new StaticTilemap(this.state, mapData, x, y, tileWidth, tileHeight, mapWidth, mapHeight, tileBorder, texture, frame));
|
||||||
},
|
},
|
||||||
|
|
||||||
make: function (config)
|
make: function (config)
|
||||||
|
|
|
@ -374,10 +374,10 @@ SpriteBatch.prototype = {
|
||||||
var sra, srb, src, srd, sre, srf, cma, cmb, cmc, cmd, cme, cmf;
|
var sra, srb, src, srd, sre, srf, cma, cmb, cmc, cmd, cme, cmf;
|
||||||
var halfTileWidth = (width) * 0.5;
|
var halfTileWidth = (width) * 0.5;
|
||||||
var halfTileHeight = (height) * 0.5;
|
var halfTileHeight = (height) * 0.5;
|
||||||
var u0 = (rectX - halfTileWidth) / textureWidth;
|
var u0 = (rectX - (halfTileWidth - 0.5)) / textureWidth;
|
||||||
var v0 = (rectY - halfTileHeight) / textureHeight;
|
var v0 = (rectY - (halfTileHeight - 0.5)) / textureHeight;
|
||||||
var u1 = (rectX + halfTileWidth) / textureWidth;
|
var u1 = (rectX + (halfTileWidth - 0.5)) / textureWidth;
|
||||||
var v1 = (rectY + halfTileHeight) / textureHeight;
|
var v1 = (rectY + (halfTileHeight - 0.5)) / textureHeight;
|
||||||
var scrollX = camera.scrollX * scrollFactorX;
|
var scrollX = camera.scrollX * scrollFactorX;
|
||||||
var scrollY = camera.scrollY * scrollFactorY;
|
var scrollY = camera.scrollY * scrollFactorY;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue