霓虹特效师
http://xuxuechao.com/ 2012-5-29 11:55:12 来源:挽弦晨笙41687 点击:
/*:
* @plugindesc 【游戏内动态霓虹标题】进入游戏后顶部显示炫彩流光霓虹标题
* @author 霓虹特效师
*
* @param === 基础设置 ===
* @default
*
* @param NeonText
* @text 霓虹显示文字
* @desc 游戏内顶部显示的霓虹标题内容
* @default 我的冒险世界
*
* @param ShowInMap
* @text 仅游戏内显示
* @type boolean
* @on 开启
* @off 关闭
* @desc 只在地图界面显示,标题/菜单不显示
* @default true
*
* @param PositionX
* @text 水平位置 X
* @type number
* @default 410
* @desc 标题在屏幕上方的X坐标
*
* @param PositionY
* @text 垂直位置 Y
* @type number
* @default 15
* @desc 标题在屏幕上方的Y坐标
*
* @param FontSize
* @text 文字大小
* @type number
* @default 28
* @desc 霓虹文字的字体大小
*
* @param === 霓虹特效设置 ===
* @default
*
* @param NeonSpeed
* @text 流光速度
* @type number
* @decimals 1
* @default 3.0
* @desc 霓虹色彩流动的速度(越大越快)
*
* @param GlowIntensity
* @text 发光强度
* @type number
* @decimals 1
* @default 2.5
* @desc 霓虹光晕的亮度
*
* @param EnableBlink
* @text 开启微闪烁
* @type boolean
* @on 开启
* @off 关闭
* @default true
* @desc 霓虹文字轻微呼吸闪烁
*
* @help
* ============================================================================
* 插件介绍
* ============================================================================
* 1. 进入游戏(地图界面)后,屏幕顶部自动生成【动态霓虹流光标题】
* 2. 标题界面、菜单界面自动隐藏,完全不影响游戏
* 3. 纯原生JS实现,无插件冲突,炫彩彩虹色动态流动
* 4. 可自定义文字、位置、大小、特效强度
*
* 特效效果:
* ✨ 彩虹色相无限循环流动
* ✨ 多层霓虹发光描边
* ✨ 轻微呼吸闪烁
* ✨ 高清发光效果
*/
(function() {
'use strict';
// ====================== 读取插件参数 ======================
const params = PluginManager.parameters('NeonGameTitle');
const NEON_TEXT = String(params.NeonText || '霓虹冒险');
const POS_X = Number(params.PositionX || 410);
const POS_Y = Number(params.PositionY || 15);
const FONT_SIZE = Number(params.FontSize || 28);
const NEON_SPEED = Number(params.NeonSpeed || 3.0);
const GLOW_INT = Number(params.GlowIntensity || 2.5);
const ENABLE_BLINK = params.EnableBlink === 'true';
const ONLY_MAP = params.ShowInMap === 'true';
// ====================== 霓虹文字精灵类 ======================
function Sprite_NeonTitle() {
this.initialize(...arguments);
}
Sprite_NeonTitle.prototype = Object.create(Sprite.prototype);
Sprite_NeonTitle.prototype.constructor = Sprite_NeonTitle;
Sprite_NeonTitle.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.x = POS_X;
this.y = POS_Y;
this._hue = 0; // 色相值(0-360)
this._blink = 0; // 闪烁计数器
this._opacity = 255;
this.createBitmap();
};
// 创建画布
Sprite_NeonTitle.prototype.createBitmap = function() {
const width = Graphics.width * 0.6;
const height = FONT_SIZE + 20;
this.bitmap = new Bitmap(width, height);
this.bitmap.fontSize = FONT_SIZE;
this.bitmap.fontItalic = true;
this.anchor.x = 0.5;
};
// 每帧更新动画
Sprite_NeonTitle.prototype.update = function() {
Sprite.prototype.update.call(this);
// 仅地图界面显示
if (ONLY_MAP && !(SceneManager._scene instanceof Scene_Map)) {
this.visible = false;
return;
}
this.visible = true;
this.updateHue();
this.updateBlink();
this.drawNeonText();
};
// 更新色相(彩虹流动)
Sprite_NeonTitle.prototype.updateHue = function() {
this._hue += NEON_SPEED;
if (this._hue > 360) this._hue = 0;
};
// 更新呼吸闪烁
Sprite_NeonTitle.prototype.updateBlink = function() {
if (!ENABLE_BLINK) return;
this._blink += 0.05;
const blinkVal = Math.sin(this._blink) * 20;
this._opacity = 235 + Math.floor(blinkVal);
};
// 绘制核心霓虹文字(多层发光 = 霓虹效果)
Sprite_NeonTitle.prototype.drawNeonText = function() {
this.bitmap.clear();
const text = NEON_TEXT;
const x = 10;
const y = 2;
// 第一层:最外层强光(最大光晕)
this.bitmap.textColor = this.getHueColor(0.8);
this.bitmap.drawText(text, x-4, y-4, 9999, FONT_SIZE);
this.bitmap.drawText(text, x+4, y-4, 9999, FONT_SIZE);
this.bitmap.drawText(text, x-4, y+4, 9999, FONT_SIZE);
this.bitmap.drawText(text, x+4, y+4, 9999, FONT_SIZE);
// 第二层:中层发光
this.bitmap.textColor = this.getHueColor(0.5);
this.bitmap.drawText(text, x-2, y-2, 9999, FONT_SIZE);
this.bitmap.drawText(text, x+2, y-2, 9999, FONT_SIZE);
this.bitmap.drawText(text, x-2, y+2, 9999, FONT_SIZE);
this.bitmap.drawText(text, x+2, y+2, 9999, FONT_SIZE);
// 第三层:核心文字
this.bitmap.textColor = '#FFFFFF';
this.bitmap.outlineColor = this.getHueColor(1);
this.bitmap.outlineWidth = Math.floor(GLOW_INT);
this.bitmap.drawText(text, x, y, 9999, FONT_SIZE);
this.bitmap.opacity = this._opacity;
};
// 色相转RGB颜色(彩虹流光核心)
Sprite_NeonTitle.prototype.getHueColor = function(alpha = 1) {
const hue = this._hue;
const r = Math.sin(hue * 0.015) * 127 + 128;
const g = Math.sin(hue * 0.015 + 2) * 127 + 128;
const b = Math.sin(hue * 0.015 + 4) * 127 + 128;
return `rgba(${r|0},${g|0},${b|0},${alpha})`;
};
// ====================== 注入游戏场景 ======================
const _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
Scene_Map.prototype.createDisplayObjects = function() {
_Scene_Map_createDisplayObjects.call(this);
// 创建霓虹标题精灵
this._neonTitle = new Sprite_NeonTitle();
this.addChild(this._neonTitle);
};
// 其他场景自动隐藏
const _Scene_Base_update = Scene_Base.prototype.update;
Scene_Base.prototype.update = function() {
_Scene_Base_update.call(this);
if (this._neonTitle) {
this._neonTitle.visible = (this instanceof Scene_Map);
}
};
})();
发表评论(0)