2017-06-09 04:00:12 +00:00
|
|
|
var TilemapWebGLRenderer = function (renderer, gameObject, interpolationPercentage, camera)
|
|
|
|
{
|
2017-08-15 22:51:37 +00:00
|
|
|
if (this.renderMask !== this.renderFlags || (this.cameraFilter > 0 && (this.cameraFilter & camera._id)))
|
2017-06-09 04:00:12 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-22 02:19:03 +00:00
|
|
|
this.cull(camera);
|
|
|
|
|
|
|
|
var renderTiles = gameObject.culledTiles;
|
2017-06-09 04:00:12 +00:00
|
|
|
var length = renderTiles.length;
|
2017-06-22 02:19:03 +00:00
|
|
|
var batch = renderer.spriteBatch;
|
|
|
|
var texture = gameObject.texture.source[0].glTexture;
|
|
|
|
var textureWidth = texture.width;
|
|
|
|
var textureHeight = texture.height;
|
|
|
|
var renderTarget = gameObject.renderTarget;
|
|
|
|
var scrollFactorX = gameObject.scrollFactorX;
|
|
|
|
var scrollFactorY = gameObject.scrollFactorY;
|
|
|
|
var alpha = gameObject.alpha;
|
|
|
|
var x = gameObject.x;
|
|
|
|
var y = gameObject.y;
|
2017-06-09 04:00:12 +00:00
|
|
|
|
|
|
|
for (var index = 0; index < length; ++index)
|
|
|
|
{
|
2017-06-22 02:19:03 +00:00
|
|
|
var tile = renderTiles[index];
|
|
|
|
batch.addTileTextureRect(
|
|
|
|
texture,
|
|
|
|
x + tile.x, y + tile.y, tile.width, tile.height, alpha * tile.alpha, tile.tint,
|
|
|
|
scrollFactorX, scrollFactorY,
|
2017-06-26 12:16:27 +00:00
|
|
|
textureWidth, textureHeight,
|
2017-06-22 02:19:03 +00:00
|
|
|
tile.frameX, tile.frameY, tile.frameWidth, tile.frameHeight,
|
|
|
|
camera,
|
|
|
|
renderTarget
|
|
|
|
);
|
2017-06-09 04:00:12 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = TilemapWebGLRenderer;
|