//=============================================================================
// MOG_MapNameHud.js
// 作用:進(jìn)入地圖,指定位置限制地圖名稱,可調(diào)整顯示位置,持續(xù)時(shí)間,讓玩家清楚的知道自己到哪兒了。
// 注:編輯地圖的時(shí)候,有“地圖名稱”、“顯示名稱”,該插件使用“顯示名稱”
//=============================================================================
/*:
* @plugindesc (v1.0) 自動(dòng)顯示地圖的名字
* @author Moghunter
*
* @param Hud X-Axis
* @desc Defini??o da posi??o X-Axis da Hud. //顯示框X軸
* @default 250
*
* @param Hud Y-Axis
* @desc Defini??o da posi??o Y-Axis da Hud. //顯示框Y軸
* @default 32
*
* @param Name X-Axis
* @desc Defini??o da posi??o X-Axis do nome. //地圖名稱X軸
* @default 105
*
* @param Name Y-Axis
* @desc Defini??o da posi??o Y-Axis do nome. //地圖名稱Y軸
* @default 30
*
* @param Duration
* @desc Defini??o do tempo de apresenta??o. //顯示持續(xù)時(shí)間
* @default 120
*
* @param Font Size
* @desc Defini??o do tamanho da fonte. //字體大小
* @default 20
*
* @help
* =============================================================================
* +++ MOG Map Name Hud(v1.0) +++
* By Moghunter
* https://atelierrgss.wordpress.com/
* =============================================================================
* Apresenta uma Hud com o nome do mapa.
* Ser?o necessários os arquivos. (img/system/)
*
* MapName.png //顯示框圖片
*
*/
//=============================================================================
// ** PLUGIN PARAMETERS
//=============================================================================
//=============================================================================
// ** PLUGIN PARAMETERS
//=============================================================================
var Imported = Imported || {};
Imported.MOG_MapNameHud = true;
var Moghunter = Moghunter || {};
Moghunter.parameters = PluginManager.parameters('MOG_MapNameHud');
//顯示框參數(shù)
Moghunter.mhud_pos_x = Number(Moghunter.parameters['Hud X-Axis'] || 250);
Moghunter.mhud_pos_y = Number(Moghunter.parameters['Hud Y-Axis'] || 32);
//地圖名稱參數(shù)
Moghunter.mhud_text_x = Number(Moghunter.parameters['Name X-Axis'] || 105);
Moghunter.mhud_text_y = Number(Moghunter.parameters['Name Y-Axis'] || 30);
Moghunter.mhud_duration = Number(Moghunter.parameters['Duration'] || 120);
Moghunter.mhud_fontsize = Number(Moghunter.parameters['Font Size'] || 20);
//=============================================================================
// ** Game_Temp
//=============================================================================
//==============================
// * Initialize
// * Game_Temp游戲臨時(shí)參數(shù),不做存儲(chǔ)
//==============================
var _alias_mog_mhud_temp_initialize = Game_Temp.prototype.initialize;
Game_Temp.prototype.initialize = function() {
_alias_mog_mhud_temp_initialize.call(this);
this._mhud_sprite = [false,0,0];
this._mhud_data = [false,null,0];
};
//=============================================================================
// ** Spriteset Map
//=============================================================================
//==============================
// * Create Upper Layer
//==============================
var _alias_mog_mhud_sprmap_createUpperLayer = Spriteset_Map.prototype.createUpperLayer;
Spriteset_Map.prototype.createUpperLayer = function() {
_alias_mog_mhud_sprmap_createUpperLayer.call(this);
this.create_mapname_hud();
};
//==============================
// * Create Map Name HUD
// * 創(chuàng)建地圖名稱顯示
//==============================
Spriteset_Map.prototype.create_mapname_hud = function() {
this._mapNameHud = new Map_Name_Hud();
this.addChild(this._mapNameHud);
if (this.needRefreshMhud()) { //刷新檢查
$gameTemp._mhud_data[0] = true;
$gameTemp._mhud_data[1] = $gameMap.displayName();
};
if ($gameTemp._mhud_data[2] != $gameMap._mapId) {
$gameTemp._mhud_sprite = [false,0,0]
};
$gameTemp._mhud_data[2] = $gameMap._mapId;
};
//==============================
// * Need Refresh MHud
// * 名稱顯示是否可用
// * 臨時(shí)參數(shù)_mhud_data[2]與地圖中地圖Id是否一致
// * 地圖顯示名稱為是否空
//==============================
Spriteset_Map.prototype.needRefreshMhud = function() {
if (!$gameMap.isNameDisplayEnabled()) {return false};
if ($gameTemp._mhud_data[2] === $gameMap._mapId) {return false};
if (!$gameMap.displayName()) {return false};
return true;
};
//=============================================================================
// * Map_Name_Hud
//=============================================================================
function Map_Name_Hud() {
this.initialize.apply(this, arguments);
};
//繼承自Sprite
Map_Name_Hud.prototype = Object.create(Sprite.prototype);
Map_Name_Hud.prototype.constructor = Map_Name_Hud;
//==============================
// * Initialize
//==============================
Map_Name_Hud.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
//位置信息
this._pos_x = Moghunter.mhud_pos_x;
this._pos_y = Moghunter.mhud_pos_y;
this.load_img(); //加載顯示框指向this._layout_img
this.create_sprites(); //創(chuàng)建顯示精靈
this.opacity = $gameTemp._mhud_sprite[1]; //臨時(shí)參數(shù)中取透明度
this.refresh();
};
//==============================
// * Load Img
//==============================
Map_Name_Hud.prototype.load_img = function() {
this._layout_img = ImageManager.loadSystem("MapName");
};
//==============================
// * Create Layout
//==============================
Map_Name_Hud.prototype.create_layout = function() {
this._layout = new Sprite(this._layout_img);
this._layout.x = this._pos_x;
this._layout.y = this._pos_y;
this.addChild(this._layout);
};
//==============================
// * Create Text
// * 名稱字符創(chuàng)建
//==============================
Map_Name_Hud.prototype.create_text = function() {
this._text = new Sprite(new Bitmap(160,32));
this._text.x = this._pos_x + Moghunter.mhud_text_x;
this._text.y = this._pos_y + Moghunter.mhud_text_y;
this._text.bitmap.fontSize = Moghunter.mhud_fontsize;
this.addChild(this._text);
};
//==============================
// * Create Sprites
//==============================
Map_Name_Hud.prototype.create_sprites = function() {
this.create_layout();
this.create_text();
};
//==============================
// * Name
// * 地圖顯示名稱
//==============================
Map_Name_Hud.prototype.name = function() {
return $gameTemp._mhud_data[1];
};
//==============================
// * Refresh Init
//==============================
Map_Name_Hud.prototype.refresh_init = function() {
$gameTemp._mhud_data[0] = false;
$gameTemp._mhud_sprite = [true,0,0];
this.x = -50;
this.opacity = 0;
};
//==============================
// * Refresh
//==============================
Map_Name_Hud.prototype.refresh = function() {
if ($gameTemp._mhud_data[0]) {
this.refresh_init()
};
if (!this.name()) {return};
this.refresh_name();
};
//==============================
// * Refresh Name
//==============================
Map_Name_Hud.prototype.refresh_name = function() {
this._text.bitmap.clear();
this._text.bitmap.drawText(this.name(),0,0,160,32,"center");
};
//==============================
// * Update visible
// * 淡入、持續(xù)展示、淡出
//==============================
Map_Name_Hud.prototype.update_position = function() {
$gameTemp._mhud_sprite[1] += 1;
if ($gameTemp._mhud_sprite[1] < 30) {
this.opacity += 8.5;
this.x += 1.6;
} else if ($gameTemp._mhud_sprite[1] < 20 + Moghunter.mhud_duration) {
this.x = 0;
this.opacity = 255;
} else {
this.opacity -= 8.5;
this.x += 1.6;
if (this.opacity === 0) {
$gameTemp._mhud_sprite[0] = false
};
};
};
//==============================
// * Update
//==============================
Map_Name_Hud.prototype.update = function() {
Sprite.prototype.update.call(this);
if ($gameTemp._mhud_sprite[0]) {
this.update_position()
} else {
this.opacity = 0
};
if ($gameTemp._mhud_data[0]) {this.refresh()};
};
//=============================================================================
// * Refresh
//=============================================================================
//==============================
// * Refresh
//==============================
Window_MapName.prototype.refresh = function() {
this.contents.clear();
};
MOG_MapNameHud.js【中文注解】【地圖名稱顯示】
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。