migalib
Version:
MIGAlib - MInimal GAme LIBrary
28 lines (27 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextureRegion = void 0;
var texturemanager_1 = require("./texturemanager");
var TextureRegion = /** @class */ (function () {
function TextureRegion(textureName, frameX, frameY, frameWidth, frameHeight) {
this.texture = texturemanager_1.TextureManager.getTexture(textureName);
var fix = 0;
var invTexWidth = 1 / this.texture.width;
var invTexHeight = 1 / this.texture.height;
this.u0 = (frameX + fix) * invTexWidth;
this.v0 = (frameY + fix) * invTexHeight;
this.u1 = (frameX + frameWidth - fix) * invTexWidth;
this.v1 = (frameY + frameHeight - fix) * invTexHeight;
this.width = frameWidth - fix;
this.height = frameHeight - fix;
// this.u0 = frameX / this.texture.width;
/* this.u0 = frameX * (1 / this.texture.width);
this.v0 = frameY * (1 / this.texture.height);
this.u1 = this.u0 + frameWidth * (1 / this.texture.width);
this.v1 = this.v0 + frameHeight * (1 / this.texture.height);*/
this.halfWidth = (frameWidth - fix) / 2;
this.halfHeight = (frameHeight - fix) / 2;
}
return TextureRegion;
}());
exports.TextureRegion = TextureRegion;