Phaser.TextureFrame = function (texture, name, sourceIndex, x, y, width, height){ this.texture = texture; this.name = name; this.source = texture.source[sourceIndex]; this.sourceIndex = sourceIndex; this.cutX = x; this.cutY = y; this.cutWidth = width; this.cutHeight = height; this.x = 0; this.y = 0; this.width = width; this.height = height; this.rotated = false ; this.isTiling = false ; this.requiresReTint = false ; this.autoRound = -1; this.data = { cut: { x: x, y: y, w: width, h: height, r: x + width, b: y + height} , trim: false , sourceSize: { w: width, h: height} , spriteSourceSize: { x: 0, y: 0, w: width, h: height} , uvs: { x0: 0, y0: 0, x1: 0, y1: 0, x2: 0, y2: 0, x3: 0, y3: 0} } ; this.updateUVs(); } ; Phaser.TextureFrame.prototype.constructor = Phaser.TextureFrame; Phaser.TextureFrame.prototype = { setTrim: function (actualWidth, actualHeight, destX, destY, destWidth, destHeight){ this.data.trim = true ; this.data.sourceSize.w = actualWidth; this.data.sourceSize.h = actualHeight; this.data.spriteSourceSize.x = destX; this.data.spriteSourceSize.y = destY; this.data.spriteSourceSize.w = destWidth; this.data.spriteSourceSize.h = destHeight; this.x = destX; this.y = destY; this.width = destWidth; this.height = destHeight; this.updateUVs(); return this; } , updateUVs: function (){ var tw = this.source.width; var th = this.source.height; var uvs = this.data.uvs; uvs.x0 = this.cutX / tw; uvs.y0 = this.cutY / th; uvs.x1 = (this.cutX + this.cutWidth) / tw; uvs.y1 = this.cutY / th; uvs.x2 = (this.cutX + this.cutWidth) / tw; uvs.y2 = (this.cutY + this.cutHeight) / th; uvs.x3 = this.cutX / tw; uvs.y3 = (this.cutY + this.cutHeight) / th; return this; } , updateUVsInverted: function (){ var tw = this.source.width; var th = this.source.height; var uvs = this.data.uvs; uvs.x0 = this.cutX / tw; uvs.y0 = this.cutY / th; uvs.x1 = (this.cutX + this.cutHeight) / tw; uvs.y1 = this.cutY / th; uvs.x2 = (this.cutX + this.cutHeight) / tw; uvs.y2 = (this.cutY + this.cutWidth) / th; uvs.x3 = this.cutX / tw; uvs.y3 = (this.cutY + this.cutWidth) / th; return this; } , clone: function (){ var clone = new Phaser.TextureFrame(this.texture, this.name, this.sourceIndex); clone.cutX = this.cutX; clone.cutY = this.cutY; clone.cutWidth = this.cutWidth; clone.cutHeight = this.cutHeight; clone.x = this.x; clone.y = this.y; clone.width = this.width; clone.height = this.height; clone.rotated = this.rotated; clone.data = Phaser.Utils.extend(true , clone.data, this.data); clone.updateUVs(); return clone; } , destroy: function (){ } } ; Object.defineProperties(Phaser.TextureFrame.prototype, { realWidth: { enumerable: true , get: function (){ return this.data.sourceSize.w; } } , realHeight: { enumerable: true , get: function (){ return this.data.sourceSize.h; } } , uvs: { enumerable: true , get: function (){ return this.data.uvs; } } } );