@osbjs/osbjs
Version:
a minimalist osu! storyboarding framework
40 lines (39 loc) • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Sprite = void 0;
const Enums_1 = require("../Enums");
const Utils_1 = require("../Utils");
const Commandable_1 = require("./Commandable");
class Sprite extends Commandable_1.Commandable {
/**
* Create a new sprite.
* A sprite is a special component, therefore you can register it to storyboard directly, or add it to another components.
* However, you can not add another components to it.
* @param path Path to the image file relative to the beatmap folder.
* @param layer The layer the object appears on.
* @param origin is where on the image should osu! consider that image's origin (coordinate) to be.
* This affects the (x) and (y) values, as well as several other command-specific behaviours.
* For example, choosing (origin) = TopLeft will let the (x),(y) values determine,
* where the top left corner of the image itself should be on the screen.
* @param initialPosition Where the sprite should be by default.
*/
constructor(path, layer = Enums_1.Layer.Background, origin = Enums_1.Origin.Center, initialPosition = new Utils_1.OsbVector2(320, 240)) {
super();
this.name = 'Sprite';
this.path = path;
this.layer = layer;
this.origin = origin;
this.initialPosition = initialPosition;
}
getOsbString() {
let str = `Sprite,${this.layer},${this.origin},"${this.path}",${this.initialPosition.x},${this.initialPosition.y}\n`;
this.commands.forEach((command) => {
str += ` ${command.getOsbString()}\n`;
});
return str;
}
registerComponents() {
throw new Error('Cannot register any components to Sprite.');
}
}
exports.Sprite = Sprite;