扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 121|回复: 0

[转载发布] 一个和namepop相似的插件,支持事件页切换时变更显示文字

[复制链接]
累计送礼:
0 个
累计收礼:
0 个
  • TA的每日心情
    开心
    2025-3-29 03:52
  • 签到天数: 127 天

    连续签到: 11 天

    [LV.7]常住居民III

    2349

    主题

    420

    回帖

    1万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    6
    卡币
    11309
    OK点
    16
    推广点
    0
    同能卷
    0
    积分
    14106

    灌水之王

    发表于 2024-2-16 22:58:40 | 显示全部楼层 |阅读模式
    这是一个从MOG系列系统中抽出来的一个插件,原来的名字叫做MOG_EventText.js.
    它的作用和namepop一致,不同之处在于不像namepop那样可以单独定义字体的大小和位置。
    但优点在于它的注释是以说明(注释)的形式写在事件页当中的,而不是事件注释位置,这样就可以做到namepop无法做到的一件事:同一事件在执行不同事件页的时候显示不同的名字。
    之前也是有朋友在namepop中问到这个功能,虽然原始的namepop不是我发的,但还是应该帮助有需要的朋友。
    当时他给了我一个日文插件,但是我没弄懂,所以我就拿MOG_EventText.js,稍微改了下让它可以注释颜色,以满足那位朋友的需要。
    这个插件的用法是:在事件页里面的第一行(注意不是事件名称和注释栏,是些事件内容的页面里),选择事件命令里面左下角的那个说明(以前叫注释)的选项,然后写入eventtext|测试|#ff0000。注意分割符,中间不留空格。颜色不能为空,为空会显示奇异的黑色= =白色的代码是#ffffff。
    你可以在同一个事件的不同页中设置不同的标签,通过独立开关或者其他让事件激活不同页的方式来切换事件头上显示的文字。
    以下为代码。
    1. //=============================================================================// MOG_EventText.js//=============================================================================/*: * @plugindesc (v1.0) Adiciona um texto em cima do evento. * @author Moghunter * * @param X axis * @desc Definição da posição X-axis. * @default 0 * * @param Y axis * @desc Definição da posição Y-axis. * @default 0 * * @param Font Size * @desc Definição do tamanho da fonte. * @default 18  * * @help   * ============================================================================= * +++ MOG - Event Text (v1.0) +++ * By Moghunter  * https://atelierrgss.wordpress.com/ * ============================================================================= * Adiciona um texto acima do evento, útil para fazer tutoriais. * ============================================================================= * Para ativar o texto no evento use o seguinte comentário no evento. * *  event text: TEXT * * Exemplo. * *  event text: I'm The Boss * *///=============================================================================// ** PLUGIN PARAMETERS//=============================================================================  var Imported = Imported || {};  Imported.MOG_EventText = true;  var Moghunter = Moghunter || {};    Moghunter.parameters = PluginManager.parameters('MOG_EventText');    Moghunter.charText_x = Number(Moghunter.parameters['X axis'] || 0);        Moghunter.charText_y = Number(Moghunter.parameters['Y axis'] || 0);    Moghunter.charText_Size = Number(Moghunter.parameters['Font Size'] || 18);        //=============================================================================// ** Character Base//=============================================================================//==============================// * Init Members//==============================var _alias_mog_eventext_cbase_initMembers = Game_CharacterBase.prototype.initMembers;Game_CharacterBase.prototype.initMembers = function() {    _alias_mog_eventext_cbase_initMembers.call(this);        this._char_text = [false,""];};//=============================================================================// ** Game Event//=============================================================================//==============================// * Setup Page//==============================var _alias_mog_eventext_gevent_setupPage = Game_Event.prototype.setupPage;Game_Event.prototype.setupPage = function() {        _alias_mog_eventext_gevent_setupPage.call(this);    this.check_event_text();};//==============================// * Check Event Text//==============================Game_Event.prototype.check_event_text = function() {        this._need_clear_text = true        if (!this._erased && this.page()) {this.list().forEach(function(l) {               if (l.code === 108) {var comment = l.parameters[0].split('|')                           if (comment[0].toLowerCase() == "eventtext"){                  this._char_text = [true,String(comment[1]),String(comment[2])];                                  this._need_clear_text = false;                                                     };};        }, this);};        if (this._need_clear_text) {this._char_text = [true,""]};};//=============================================================================// ** Sprite Character//=============================================================================//==============================// * Initialize//==============================var _alias_mog_eventext_schar_initialize = Sprite_Character.prototype.initialize;Sprite_Character.prototype.initialize = function(character) {    _alias_mog_eventext_schar_initialize.call(this,character);        if (this._character && this._character._eventId) {this._character.check_event_text()};};//=============================================================================// ** Spriteset Map//=============================================================================//==============================// * create Lower Layer//==============================var _alias_mog_eventext_srmap_createLowerLayer = Spriteset_Map.prototype.createLowerLayer;Spriteset_Map.prototype.createLowerLayer = function() {        _alias_mog_eventext_srmap_createLowerLayer.call(this);        this.create_event_text_field();};//==============================// * create Event Text Field//==============================Spriteset_Map.prototype.create_event_text_field = function() {        this._etextField = new Sprite();        this._baseSprite.addChild(this._etextField);        this._sprite_char_text = [];        for (var i = 0; i < this._characterSprites.length; i++) {             this._sprite_char_text[i] = new Sprite_CharText(this._characterSprites[i]);                 this._etextField.addChild(this._sprite_char_text[i]);    };};//=============================================================================// ** Sprite CharText//=============================================================================function Sprite_CharText() {    this.initialize.apply(this, arguments);};Sprite_CharText.prototype = Object.create(Sprite.prototype);Sprite_CharText.prototype.constructor = Sprite_CharText;//==============================// * Initialize//==============================Sprite_CharText.prototype.initialize = function(target) {    Sprite.prototype.initialize.call(this);        this.sprite_char = target;};//==============================// * Character//==============================Sprite_CharText.prototype.character = function() {         return this.sprite_char._character;};//==============================// * Update Char Text//==============================Sprite_CharText.prototype.update = function() {        Sprite.prototype.update.call(this);        if (this.character()._char_text[0]) {this.refresh_char_text()};        if (!this._char_text) {return};        this._char_text.x = this.textX_axis();        this._char_text.y = this.textY_axis();};//==============================// * Create Char Text//==============================Sprite_CharText.prototype.create_char_text = function() {         if (this._char_text) {this.removeChild(this._char_text)};         if (this.character()._char_text[1] === "") {return};     this._char_text = new Sprite(new Bitmap(90,32));         this._char_text.anchor.x = 0.5;         this._char_text.y = -(this.sprite_char.patternHeight());         this._char_text.bitmap.fontSize = Moghunter.charText_Size;         this.addChild(this._char_text);};//==============================// * Refresh Char Text//==============================Sprite_CharText.prototype.refresh_char_text = function() {    this.create_char_text();        this.character()._char_text[0] = false;        if (this.character()._char_text[1] === "") {return};        var text = this.character()._char_text[1];        this._char_text.bitmap.clear();        var color = this.character()._char_text[2];        this._char_text.bitmap.textColor = color;        this._char_text.bitmap.drawText(text,0,0,90,32,"center");};//==============================// * Text X Axis//==============================Sprite_CharText.prototype.textX_axis = function() {        return Moghunter.charText_x + this.sprite_char.x;};//==============================// * Text Y Axis//==============================Sprite_CharText.prototype.textY_axis = function() {        return -(this.sprite_char.patternHeight() + 24) + Moghunter.charText_y + this.sprite_char.y;};复制代码
    复制代码
                本帖来自P1论坛作者salvareless,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=388540  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2025-4-20 11:44 , Processed in 0.120694 second(s), 53 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表