Код:
//=============================================================================
//Yuryol_Hud2.js
//=============================================================================
/*:
* @plugindesc Худ-бар
* @author Yuryol
*/
(function() {
var Scene_Map_create_alias = Scene_Map.prototype.onMapLoaded;
Scene_Map.prototype.onMapLoaded = function() {
Scene_Map_create_alias.call(this);
this.hp_hud = new HP_hud();
this.face_hud = new FACE_hud();
this.addChild(this.hp_hud);
this.addChild(this.face_hud);
};
/********************
HP hud
********************/
function HP_hud() {
this.initialize.apply(this, arguments);
};
HP_hud.prototype = Object.create(Sprite.prototype);
HP_hud.prototype.constructor = HP_hud;
HP_hud.prototype.initialize = function () {
Sprite.prototype.initialize.call(this);
this.x = 65;
this.y = 20;
this.bitmap = new Bitmap(110, 50);
this.update();
};
HP_hud.prototype.update = function(){
var equip0 = $gameParty.leader().equips()[0];
this.bitmap.clear();
this.drawHud();
if (equip0 !==null) {
var icon0 = equip0.iconIndex;
this.drawIcon(icon0,90, 0, 20, 20);
};
};
HP_hud.prototype.drawHud = function () {
this.bitmap.clear();
var abshp = $gameParty.leader().hp;
var maxhp = $gameParty.leader().mhp;
var hp = 80 * abshp / maxhp;
this.bitmap.fillRect(0, 0, 80, 20, '#000');
this.bitmap.fillRect(0, 0, hp, 20, '#d70f0f');
var absmp = $gameParty.leader().mp;
var maxmp = $gameParty.leader().mmp;
var mp = 80 * absmp / maxmp;
this.bitmap.fillRect(0, 25, 80, 20, '#000');
this.bitmap.fillRect(0, 25, mp, 20, '#d70f0f');
};
HP_hud.prototype.drawIcon = function(index,x, y, w, h) {
if (!this.bitmap) return false;
var bitmap = ImageManager.loadSystem('IconSet');
var pw = Window_Base._iconWidth;
var ph = Window_Base._iconHeight;
var sx = index%16*pw;
var sy = Math.floor(index/16)*pw;
this.bitmap.blt(bitmap,sx,sy,pw,ph,x,y, w, h);
return true;
};
/********************
FACE hud
********************/
function FACE_hud() {
this.initialize.apply(this, arguments);
};
FACE_hud.prototype = Object.create(Sprite.prototype);
FACE_hud.prototype.constructor = FACE_hud;
FACE_hud.prototype.initialize = function () {
Sprite.prototype.initialize.call(this);
this.x = 20;
this.y = 20;
this.bitmap = new Bitmap(40, 40);
this.update();
};
FACE_hud.prototype.update = function(){
this.drawIcon($gameParty.members()[0].faceName(),$gameParty.members()[0].faceIndex(), 0, 0, 40, 40);
};
FACE_hud.prototype.drawIcon = function(faceName,index, x, y, w, h) {
if (!this.bitmap) return false;
var bitmap = ImageManager.loadFace(faceName);
var pw = Window_Base._faceWidth;
var ph = Window_Base._faceHeight;
var sx = index%4*pw;
var sy = Math.floor(index/4)*pw;
this.bitmap.blt(bitmap,sx,sy,pw,ph,x,y, w, h);
return true;
};
})()
Социальные закладки