2017-04-25 22:09:13 +00:00
|
|
|
|
|
|
|
var Class = require('../../utils/Class');
|
|
|
|
var GameObject = require('../GameObject');
|
|
|
|
var Components = require('../../components');
|
|
|
|
var TileSpriteRender = require('./TileSpriteRender');
|
2017-04-28 18:10:32 +00:00
|
|
|
var CanvasPool = require('../../dom/CanvasPool')
|
2017-04-25 22:09:13 +00:00
|
|
|
|
|
|
|
var TileSprite = new Class({
|
|
|
|
|
|
|
|
Extends: GameObject,
|
|
|
|
|
|
|
|
Mixins: [
|
|
|
|
Components.Alpha,
|
|
|
|
Components.BlendMode,
|
|
|
|
Components.Flip,
|
|
|
|
Components.GetBounds,
|
|
|
|
Components.Origin,
|
|
|
|
Components.RenderTarget,
|
|
|
|
Components.ScaleMode,
|
|
|
|
Components.Size,
|
|
|
|
Components.Texture,
|
|
|
|
Components.Transform,
|
|
|
|
Components.Visible,
|
|
|
|
TileSpriteRender
|
|
|
|
],
|
|
|
|
|
|
|
|
initialize:
|
|
|
|
|
2017-04-28 18:10:32 +00:00
|
|
|
function TileSprite (state, x, y, width, height, texture, frame)
|
2017-04-25 22:09:13 +00:00
|
|
|
{
|
2017-04-28 18:10:32 +00:00
|
|
|
var resourceManager = state.game.renderer.resourceManager;
|
|
|
|
var gl;
|
|
|
|
|
2017-04-25 22:09:13 +00:00
|
|
|
GameObject.call(this, state, 'TileSprite');
|
|
|
|
|
|
|
|
this.tilePositionX = 0;
|
|
|
|
this.tilePositionY = 0;
|
2017-04-28 18:10:32 +00:00
|
|
|
this.canvasBuffer = CanvasPool.create2D(null, width, height);
|
|
|
|
this.canvasBufferCtx = this.canvasBuffer.getContext('2d');
|
|
|
|
this.dirty = false;
|
2017-04-25 22:09:13 +00:00
|
|
|
|
|
|
|
this.setTexture(texture, frame);
|
|
|
|
this.setPosition(x, y);
|
|
|
|
this.setSizeToFrame();
|
|
|
|
this.setOrigin();
|
2017-04-28 18:10:32 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
updateTileTexture: function ()
|
|
|
|
{
|
|
|
|
|
2017-04-25 22:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = TileSprite;
|