alter-egoism/js/plugins/CBR_fukidashi.js
2025-11-01 14:17:42 -05:00

29 lines
995 B
JavaScript

Sprite_Balloon.prototype.setup = function (targetSprite, balloonId) {
this._target = targetSprite;
this._balloonId = balloonId;
this._duration = 10 * this.speed() + this.waitTime();
};
Sprite_Balloon.prototype.loadBitmap = function () {
this.bitmap = ImageManager.loadSystem("fukidashi_ori");
this.setFrame(0, 0, 0, 0);
};
Sprite_Balloon.prototype.frameIndex = function () {
const index = (this._duration - this.waitTime()) / this.speed();
return 7 - Math.max(Math.floor(index), 0);
};
Sprite_Balloon.prototype.updateFrame = function () {
const w = 48;
const h = 48;
var sx = (this._balloonId % 4) * w * 5; //初期位置
sx += (this.frameIndex() % 5) * w;
var sy = Math.floor(this._balloonId / 4) * h * 2;
sy += Math.floor(this.frameIndex() / 5) * h;
this.setFrame(sx, sy, w, h);
};
Sprite_Balloon.prototype.frameIndex = function () {
const index = (this._duration - this.waitTime()) / this.speed();
return 9 - Math.max(Math.floor(index), 0);
};