设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 6429|回复: 5

[原创发布] EKMOMO的MV笔记(插件篇)

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3394
在线时间
461 小时
注册时间
2013-12-7
帖子
333
发表于 2016-11-29 17:22:41 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 ekmomo 于 2016-11-29 17:33 编辑
伸手党: LogoMap.zip (696 Bytes, 下载次数: 164)

本帖不定时更新,渣排版勿喷。

昨天晚上入坑MV,第一时间体验插件系统,网上的评论有很多,我也不想做过多的评价。
所谓的JS插件其实并没有我想象中的友好,对我本人来说无所谓,但对于一个没有接触过RGSS的人来说,JS只是基础……


DAY1 打开游戏时载入LOGO
其实早在xp时代,自制脚本就有利用RM从上到下读取脚本内容,重新定义系统方法来自定游戏的传统。


系统代码:
  1. Scene_Boot.prototype.start = function() {
  2.     Scene_Base.prototype.start.call(this);
  3.     SoundManager.preloadImportantSounds();
  4.     if (DataManager.isBattleTest()) {
  5.         DataManager.setupBattleTest();
  6.         SceneManager.goto(Scene_Battle);
  7.     } else if (DataManager.isEventTest()) {
  8.         DataManager.setupEventTest();
  9.         SceneManager.goto(Scene_Map);
  10.     } else {
  11.         this.checkPlayerLocation();
  12.         DataManager.setupNewGame();
  13.         SceneManager.goto(Scene_Title);
  14.         Window_TitleCommand.initCommandPosition();
  15.     }
  16.     this.updateDocumentTitle();
  17. };
复制代码

插件代码:


  1. Scene_Boot.prototype.start = function() {
  2.     Scene_Base.prototype.start.call(this);
  3.     SoundManager.preloadImportantSounds();
  4.     if (DataManager.isBattleTest()) {
  5.         DataManager.setupBattleTest();
  6.         SceneManager.goto(Scene_Battle);
  7.     } else if (DataManager.isEventTest()) {
  8.         DataManager.setupEventTest();
  9.         SceneManager.goto(Scene_Map);
  10.     } else {
  11.         this.checkPlayerLocation();
  12.         DataManager.setupNewGame();
  13.         $gamePlayer.reserveTransfer(logomap, 0, 0);
  14.         SceneManager.goto(Scene_Map);
  15.         Window_TitleCommand.initCommandPosition();
  16.     }
  17.     this.updateDocumentTitle();
  18. };
复制代码



我们重置了游戏开始时的方法。


系统代码中
  1. SceneManager.goto(Scene_Title);
复制代码
的意思是,将
场景管理器跳转到Scene_Title


而我们
  1. <font color="#000000">$gamePlayer.reserveTransfer(logomap, 0, 0);
  2. SceneManager.goto(Scene_Map);</font>
复制代码


直译是:将Player放在某地图的0,0坐标然后将场景管理器跳转到Scene_Map

tips:为什么要建一张地图来操作LOGO?
答:因为 事件(劇情)(Event)在地图编辑器中非常强大,你可以制作非常独特的内容。而且脚本——地图——事件本身就是一个很好的逻辑,如果你能理解MVC就能很好的理解这样的做法了。
虽然,这么做也有许多缺点。不过仅就我本人的来说,我更习惯这么做。

所谓某地图是我们使用插件管理器的一个功能——参数:

  1. /*:
复制代码

我们在插件开始时声明参数,RM编辑器从声明中得到三条信息,从上到下依次是【参数名】【说明】【默认值】。

并在插件中使用参数:
  1. var parameters = PluginManager.parameters('LogoMap');
  2. var logomap = Number(parameters['logomap'] || 1);
复制代码
第一行代码 读取 plugins文件夹下以
LogoMap命名的js文件的参数,并将其以数组的形式赋值给parameters
第二行代码 是定义一个 Number类型的对象,并从parameters数组中取logomap的值,当logomap为undefined 或null时,以1为默认值


翻译过来就是,我们把logomap从参数变成了一个可以调用的值~

如何定义一个载入事件



评分

参与人数 4星屑 +224 +1 收起 理由
白嫩白嫩的 + 1 精品文章
刺夜之枪 + 66 我很赞同
柳岳枫 + 60 精品文章
king + 98 精品文章

查看全部评分

Lv1.梦旅人

梦石
0
星屑
50
在线时间
180 小时
注册时间
2008-2-6
帖子
92
发表于 2016-11-29 22:17:06 | 显示全部楼层
是的MV插件系统真的不友好,没有系统的表格,每次都是直接看源码
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3394
在线时间
461 小时
注册时间
2013-12-7
帖子
333
 楼主| 发表于 2016-12-27 23:04:35 | 显示全部楼层

EKMOMO的MV笔记(插件篇)

本帖最后由 ekmomo 于 2016-12-27 23:08 编辑

DAY2 我要做一个手机页游
终于到Day2了么……本人因为年终工作较忙,以及母亲大人脚踝扭伤,蜗牛更跟大家道歉了先……

调整窗口分辨率:
  1. //=============================================================================
  2. // ** 窗口分辨率 全屏
  3. //=============================================================================
  4. EKM_visual_viewport                =        window.innerWidth/window.innerHeight;
  5. EKM_body_width                        =        816;
  6. EKM_body_height                        =        EKM_body_width/EKM_visual_viewport;
  7. SceneManager._screenWidth  = EKM_body_width;
  8. SceneManager._screenHeight = EKM_body_height;
  9. SceneManager._boxWidth     = EKM_body_width;
  10. SceneManager._boxHeight    = EKM_body_height;
复制代码
手机浏览器分辨率的问题可以讲一天,伸手党直接拿去用就好~(通过修改 宽度值【816】来定义分辨率 ,这个值小于816要使用配套的window插件)
想要更深入的同学 需要注意的是:
主流触屏智能手机绝大多数浏览器body宽度980 PX, 而高度则不尽相同 (如safari与UC 在IPHONE 7PLUS 上 为1487 而微信内置浏览器为1591 PX,而不同机型相同浏览器也会有差异),但是好在mv游戏是一个禁止手动缩放的页面,所以这个脚本通过计算visual viewport来动态赋值游戏窗口的高度。

选项单次点击:

  1. //=============================================================================
  2. // ** 选项单次点击
  3. //=============================================================================        
  4. Window_Selectable.prototype.onTouch = function(triggered) {
  5.     var lastIndex = this.index();
  6.     var x = this.canvasToLocalX(TouchInput.x);
  7.     var y = this.canvasToLocalY(TouchInput.y);
  8.     var hitIndex = this.hitTest(x, y);
  9.     if (hitIndex >= 0) {
  10.         if (hitIndex === this.index()) {
  11.             if (triggered && this.isTouchOkEnabled()) {
  12.                 this.processOk();
  13.             }
  14.         } else if (this.isCursorMovable()) {
  15.             this.select(hitIndex);
  16.                         this.processOk();
  17.         }
  18.     } else if (this._stayCount >= 10) {
  19.         if (y < this.padding) {
  20.             this.cursorUp();
  21.         } else if (y >= this.height - this.padding) {
  22.             this.cursorDown();
  23.         }
  24.     }
  25.     if (this.index() !== lastIndex) {
  26.         SoundManager.playCursor();
  27.     }
  28. };
复制代码

这个插件的目的是在移动端解决两次点击(一次选择,一次确认)选项的问题,整队命令中我需要点至少四下手指来换人真的不蠢么~而实现方法也是较为简单的,就是在选项的坐标点选过程中加入了一条processOk命令~


游戏开始方式:

  1. //=============================================================================
  2. // ** 游戏开始方式
  3. //=============================================================================        
  4. Scene_Boot.prototype.start = function() {
  5.     Scene_Base.prototype.start.call(this);
  6.     SoundManager.preloadImportantSounds();
  7.     if (DataManager.isBattleTest()) {
  8.         DataManager.setupBattleTest();
  9.         SceneManager.goto(Scene_Battle);
  10.     } else if (DataManager.isEventTest()) {
  11.         DataManager.setupEventTest();
  12.         SceneManager.goto(Scene_Map);
  13.     } else if (DataManager.isAnySavefileExists()){
  14.                 DataManager.loadGame(1);
  15.         SceneManager.goto(Scene_Map);
  16.         }
  17.         else {
  18.         this.checkPlayerLocation();
  19.         DataManager.setupNewGame();
  20.         SceneManager.goto(Scene_Map);
  21.         Window_TitleCommand.initCommandPosition();
  22.     }
  23.     this.updateDocumentTitle();
  24. };
复制代码


在Day1的基础上改造的,在跳过标题画面的基础上,有存档自动读取存档一,无存档开始新游戏。
回复 支持 1 反对 1

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3394
在线时间
461 小时
注册时间
2013-12-7
帖子
333
 楼主| 发表于 2016-12-27 23:16:14 | 显示全部楼层
菜单整合
JAVASCRIPT 代码复制
  1. //=============================================================================
  2. // ** 菜单整合
  3. //=============================================================================       
  4. Window_MenuCommand.prototype.makeCommandList = function() {
  5.     this.addMainCommands();
  6.     this.addFormationCommand();
  7.     this.addOriginalCommands();
  8.     this.addGameEndCommand();
  9.     this.addCommand('返回', 'cancel');
  10. };
  11.  
  12. Window_MenuCommand.prototype.addGameEndCommand = function() {
  13.     var enabled = this.isGameEndEnabled();
  14.     this.addCommand('系统', 'gameEnd', enabled);
  15. };
  16.  
  17. Window_GameEnd.prototype.itemTextAlign = function() {
  18.     return 'center';
  19. };
  20. Window_GameEnd.prototype.makeCommandList = function() {
  21.         this.addCommand('读档', 'load', DataManager.isAnySavefileExists());
  22.         this.addCommand('存档', 'save');
  23.     this.addCommand('重开', 'reset');
  24.         this.addCommand('设置', 'options');
  25.     this.addCommand('返回',  'cancel');
  26. };
  27. Scene_GameEnd.prototype.createCommandWindow = function() {
  28.     this._commandWindow = new Window_GameEnd();
  29.     this._commandWindow.setHandler('load',  this.commandLoad.bind(this));
  30.     this._commandWindow.setHandler('save',  this.commandSave.bind(this));
  31.     this._commandWindow.setHandler('reset',  this.commandReset.bind(this));
  32.     this._commandWindow.setHandler('options',   this.commandOptions.bind(this));
  33.     this._commandWindow.setHandler('cancel',   this.popScene.bind(this));
  34.     this.addWindow(this._commandWindow);
  35. };
  36.  
  37. Scene_GameEnd.prototype.commandSave = function() {
  38.     DataManager.saveGame(1);
  39.     SceneManager.goto(Scene_Map);
  40. };
  41. Scene_GameEnd.prototype.commandLoad = function() {
  42.     DataManager.loadGame(1);
  43.     SceneManager.goto(Scene_Map);
  44. };
  45. Scene_GameEnd.prototype.commandReset = function() {
  46.         DataManager.setupNewGame();
  47.         SceneManager.goto(Scene_Map);
  48. };
  49. Scene_GameEnd.prototype.commandOptions = function() {
  50.     SceneManager.push(Scene_Options);
  51. };
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
359
在线时间
228 小时
注册时间
2009-8-25
帖子
48
发表于 2020-2-24 21:20:26 | 显示全部楼层
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
9 小时
注册时间
2023-11-29
帖子
6
发表于 2023-12-2 13:19:43 | 显示全部楼层
新手浮力,,顶顶。。。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-3-29 20:01

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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