赞 | 35 |
VIP | 0 |
好人卡 | 0 |
积分 | 73 |
经验 | 0 |
最后登录 | 2024-11-27 |
在线时间 | 475 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 7328
- 在线时间
- 475 小时
- 注册时间
- 2021-12-4
- 帖子
- 516
|
//-----------------------------------------------------------------------------
// Sprite_Timer
//
// The sprite for displaying the timer.
function Sprite_Timer() {
this.initialize.apply(this, arguments);
}
Sprite_Timer.prototype = Object.create(Sprite.prototype);
Sprite_Timer.prototype.constructor = Sprite_Timer;
Sprite_Timer.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this._seconds = 0;
this.createBitmap();
this.update();
};
Sprite_Timer.prototype.createBitmap = function() {
this.bitmap = new Bitmap(96, 48);
this.bitmap.fontSize = 32;
};
Sprite_Timer.prototype.update = function() {
Sprite.prototype.update.call(this);
this.updateBitmap();
this.updatePosition();
this.updateVisibility();
};
Sprite_Timer.prototype.updateBitmap = function() {
if (this._seconds !== $gameTimer.seconds()) {
this._seconds = $gameTimer.seconds();
this.redraw();
}
};
Sprite_Timer.prototype.redraw = function() {
var text = this.timerText();
var width = this.bitmap.width;
var height = this.bitmap.height;
this.bitmap.clear();
this.bitmap.drawText(text, 0, 0, width, height, 'center');
};
Sprite_Timer.prototype.timerText = function() {
var min = Math.floor(this._seconds / 60) % 60;
var sec = this._seconds % 60;
return min.padZero(2) + ':' + sec.padZero(2);
};
Sprite_Timer.prototype.updatePosition = function() {
this.x = Graphics.width - this.bitmap.width;
this.y = 0;
};
Sprite_Timer.prototype.updateVisibility = function() {
this.visible = $gameTimer.isWorking();
};
以上代码位于rpg_sprites.js第2000行,可以修改updatePosition和timerText来分别修改位置和文字格式哦。 |
评分
-
查看全部评分
|