| 赞 | 58 |
| VIP | |
| 好人卡 | |
| 积分 | 12 |
| 经验 | |
| 最后登录 | 2023-5-29 |
| 在线时间 | 1017 小时 |
- 梦石
- 0
- 星屑
- 1232
- 在线时间
- 1017 小时
- 注册时间
- 2011-4-30
- 回帖
- 1464
|
发表于 2015-11-22 20:03:27
|
显示全部楼层
本帖最后由 汪汪 于 2016-2-2 01:13 编辑
主要是脸图没准备好的问题,这里参考的是Window_Message里的写法..
- //=============================================================================
- // ceshi.js
- //=============================================================================
- /*:
- * @plugindesc 测试
- * @author wangwang
- */
- (function() {
- function Window_HUD() {
- this.initialize.apply(this, arguments);
- }
- Scene_Map.prototype.createDisplayObjects = function() {
- this.createSpriteset();
- this.createMapNameWindow();
- this.createWindowLayer();
- this.createAllWindows();
- this.createHUDWindow()
- };
- Scene_Map.prototype.createHUDWindow = function() {
- this.hud = new Window_HUD();
- this.addWindow(this.hud);
-
- };
- // Window_HUD
- // HUD窗口
- function Window_HUD() {
- this.initialize.apply(this, arguments);
- }
- Window_HUD.prototype=Object.create(Window_Base.prototype);
- Window_HUD.prototype.constructor = Window_HUD;
- //初始化
- Window_HUD.prototype.initialize=function(){
- var width = this.windowWidth();
- var height = this.windowHeight();
- Window_Base.prototype.initialize.call(this, 0, 0, width, height);
- this.opacity = 255;//预设背景透明度
- this.actor = $gameActors.actor(1);
- this.old_hp = this.actor.hp;
- this.refresh();
- this.update();
- };
- //窗口宽
- Window_HUD.prototype.windowWidth = function() {
- return 144+4+186+this.standardPadding()*2;
- };
- //窗口高
- Window_HUD.prototype.windowHeight = function() {
- return 144+this.standardPadding()*2;
- };
- //刷新
- Window_HUD.prototype.refresh = function() {
- this.contents.clear();
- //让 图片管理器 读取 脸图(没有准备好图片前是绘制不了的,)
- this._faceBitmap = ImageManager.loadFace(this.actor.faceName());
- // this.drawActorFace(this.actor, 0, 0);
- // this.drawActorName(this.actor,5,100);
- this.drawActorHp(this.actor,144+4,50);
- };
- //更新数据
- Window_HUD.prototype.update = function() {
- if(this.old_hp!=this.actor.hp){
- this.refresh();
- this.old_hp=this.actor.hp;
- }
- // 如果有脸图
- if (this._faceBitmap){
- //如果 图片管理器已经准备好
- if (ImageManager.isReady()) {
- //绘制脸图(没有准备好图片前是绘制不了的)
- this.drawActorFace(this.actor, 0, 0);
- //绘制名称(后绘制的在上,所以在这里写)
- this.drawActorName(this.actor,5,100);
- this._faceBitmap = null;
- }
- }
- }
- })();
复制代码
//果然还是要读默认脚本啊 T_T- Window_Base.prototype.drawFace = function(faceName, faceIndex, x, y, width, height) {
- width = width || Window_Base._faceWidth;
- height = height || Window_Base._faceHeight;
- var bitmap = ImageManager.loadFace(faceName);
- var pw = Window_Base._faceWidth;
- var ph = Window_Base._faceHeight;
- var sw = Math.min(width, pw);
- var sh = Math.min(height, ph);
- var dx = Math.floor(x + Math.max(width - pw, 0) / 2);
- var dy = Math.floor(y + Math.max(height - ph, 0) / 2);
- var sx = faceIndex % 4 * pw + (pw - sw) / 2;
- var sy = Math.floor(faceIndex / 4) * ph + (ph - sh) / 2;
- bitmap.addLoadListener(
- this.contents.blt.bind(this.contents,bitmap, sx, sy, sw, sh, dx, dy)
- );
- };
复制代码 更新一下方法...... |
评分
-
查看全部评分
|