Phaser.TileSprite = function (game, x, y, width, height, key, frame){ x = x || 0; y = y || 0; width = width || 256; height = height || 256; key = key || null ; frame = frame || null ; this.game = game; this.name = ''; this.type = Phaser.TILESPRITE; this.events = new Phaser.Events(this); this.animations = new Phaser.AnimationManager(this); this.key = key; this._frame = 0; this._frameName = ''; this._scroll = new Phaser.Point(); PIXI.TilingSprite.call(this, PIXI.TextureCache.__default, width, height); this.loadTexture(key, frame); this.position.set(x, y); this.input = null ; this.world = new Phaser.Point(x, y); this.cameraOffset = new Phaser.Point(); this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0] ); } ; Phaser.TileSprite.prototype = Object.create(PIXI.TilingSprite.prototype); Phaser.TileSprite.prototype.constructor = Phaser.TileSprite; Phaser.TileSprite.prototype.preUpdate = function (){ this.world.setTo(this.game.camera.x + this.worldTransform[2], this.game.camera.y + this.worldTransform[5]); this.animations.update(); if (this._scroll.x !== 0) { this.tilePosition.x += this._scroll.x * this.game.time.physicsElapsed; } if (this._scroll.y !== 0) { this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed; } return true ; } ; Phaser.TileSprite.prototype.update = function (){ } ; Phaser.TileSprite.prototype.postUpdate = function (){ if (this._cache[7] === 1) { this.position.x = this.game.camera.view.x + this.cameraOffset.x; this.position.y = this.game.camera.view.y + this.cameraOffset.y; } } ; Phaser.TileSprite.prototype.autoScroll = function (x, y){ this._scroll.set(x, y); } ; Phaser.TileSprite.prototype.stopScroll = function (){ this._scroll.set(0, 0); } ; Phaser.TileSprite.prototype.loadTexture = function (key, frame){ frame = frame || 0; if (key instanceof Phaser.RenderTexture) { this.key = key.key; this.setTexture(key); return ; } else if (key instanceof Phaser.BitmapData) { this.key = key.key; this.setTexture(key.texture); return ; } else if (key instanceof PIXI.Texture) { this.key = key; this.setTexture(key); return ; } else { if (key === null || typeof key === 'undefined') { this.key = '__default'; this.setTexture(PIXI.TextureCache[this.key]); return ; } else if (typeof key === 'string' && !this.game.cache.checkImageKey(key)) { this.key = '__missing'; this.setTexture(PIXI.TextureCache[this.key]); return ; } if (this.game.cache.isSpriteSheet(key)) { this.key = key; this.animations.loadFrameData(this.game.cache.getFrameData(key)); if (typeof frame === 'string') { this.frameName = frame; } else { this.frame = frame; } } else { this.key = key; this.setTexture(PIXI.TextureCache[key]); return ; } } } ; Phaser.TileSprite.prototype.destroy = function (destroyChildren){ if (this.game === null ) { return ; } if (typeof destroyChildren === 'undefined') { destroyChildren = true ; } if (this.filters) { this.filters = null ; } if (this.parent) { if (this.parent instanceof Phaser.Group) { this.parent.remove(this); } else { this.parent.removeChild(this); } } this.animations.destroy(); this.events.destroy(); var i = _AN_Read_length('length', this.children); if (destroyChildren) { while (i-- ){ this.children[i].destroy(destroyChildren); } } else { while (i-- ){ this.removeChild(this.children[i]); } } this.exists = false ; this.visible = false ; this.filters = null ; this.mask = null ; this.game = null ; } ; Phaser.TileSprite.prototype.play = function (name, frameRate, loop, killOnComplete){ return this.animations.play(name, frameRate, loop, killOnComplete); } ; Object.defineProperty(Phaser.TileSprite.prototype, "angle", { get: function (){ return Phaser.Math.wrapAngle(Phaser.Math.radToDeg(this.rotation)); } , set: function (value){ this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(value)); } } ); Object.defineProperty(Phaser.TileSprite.prototype, "frame", { get: function (){ return this.animations.frame; } , set: function (value){ if (value !== this.animations.frame) { this.animations.frame = value; } } } ); Object.defineProperty(Phaser.TileSprite.prototype, "frameName", { get: function (){ return this.animations.frameName; } , set: function (value){ if (value !== this.animations.frameName) { this.animations.frameName = value; } } } ); Object.defineProperty(Phaser.TileSprite.prototype, "fixedToCamera", { get: function (){ return !!this._cache[7]; } , set: function (value){ if (value) { this._cache[7] = 1; this.cameraOffset.set(this.x, this.y); } else { this._cache[7] = 0; } } } ); Object.defineProperty(Phaser.TileSprite.prototype, "inputEnabled", { get: function (){ return (this.input && this.input.enabled); } , set: function (value){ if (value) { if (this.input === null ) { this.input = new Phaser.InputHandler(this); this.input.start(); } } else { if (this.input && this.input.enabled) { this.input.stop(); } } } } );