Phaser.TextureFrame = function (texture, name, sourceIndex, x, y, width, height){ this.texture = texture; this.source = texture.source[sourceIndex]; this.sourceIndex = sourceIndex; this.name = name; 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 = { crop: function (width, height, x, y){ if (width === undefined) { width = this.data.cut.w; } if (height === undefined) { height = this.data.cut.h; } if (x === undefined) { x = 0; } if (y === undefined) { y = 0; } if (width === undefined) { this.cutX = this.data.cut.x; this.cutY = this.data.cut.y; this.cutWidth = this.data.cut.w; this.cutHeight = this.data.cut.h; } else if (width !== this.cutWidth || height !== this.cutHeight || x !== this.cutX || y !== this.cutY) { this.cutX = Phaser.Math.clamp(x, this.data.cut.x, this.data.cut.r); this.cutY = Phaser.Math.clamp(y, this.data.cut.y, this.data.cut.b); this.cutWidth = Phaser.Math.clamp(width, 0, this.data.cut.w - this.cutX); this.cutHeight = Phaser.Math.clamp(height, 0, this.data.cut.h - this.cutY); } this.updateUVs(); return this; } , 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; } , resize: function (width, height){ } , clone: function (){ } , right: function (){ } , bottom: function (){ } , 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; } } } );