一共有4个需要设定的地方:
如果想给弹出的文本框设置脸图,那么就可以用这个代码。
| 参数 | 参数类型/参数内容 | 默认值 | 说明 | |
|---|---|---|---|---|
| faceName | 字符串,内容就是脸图的名字 | 就是脸图文件的名字,事件编辑器那里面选择显示文字,然后点击脸图,就会有一个弹窗。弹窗里面就是脸图的文件,这个faceName就是这些文件的名字。 | ||
| faceIndex | 0到8 | 一个脸图有8个头像,从零开始数,第一行是0到4,第二行是5到7。写几就是第几个图。 |
1$gameMessage.setFaceImage(faceName, faceIndex);| 参数 | 参数类型/参数内容 | 默认值 | 说明 | |
|---|---|---|---|---|
| background | 0:窗口 1:暗淡 2:透明 | 这个参数就对应着背景下拉框的属性 |
xxxxxxxxxx11$gameMessage.setBackground(background);| 参数 | 参数类型/参数内容 | 默认值 | 说明 | |
|---|---|---|---|---|
| positionType | 0:顶部 1:中间 2:底部 | 这个参数就对应着背景下拉框的属性 |
xxxxxxxxxx11$gameMessage.setPositionType(positionType);这个就是本指令的核心方法,效果就是弹出来文本框。如果没有配置前面的样式,那么会按照默认样式来显示。
text:这个就是一个普通的字符串
xxxxxxxxxx11$gameMessage.add(text);
示例:
xxxxxxxxxx41$gameMessage.setFaceImage("Actor1",0);2$gameMessage.setBackground(0);3$gameMessage.setPositionType(2);4$gameMessage.add("内容");
| 参数 | 参数类型/参数内容 | 默认值 | 说明 | |
|---|---|---|---|---|
| background | 0:窗口 1:暗淡 2:透明 | 窗体的样式 |
xxxxxxxxxx11$gameMessage.setChoiceBackground(0);
positionType:有三个固定的数值
0:顶部
1:中间
2:底部
xxxxxxxxxx11$gameMessage.setChoicePositionType(positionType);
| 参数 | 参数类型/参数内容 | 默认值 | 说明 | |
|---|---|---|---|---|
| choices | 数组 | 数组的内容就是选项的内容,比如["是","否"]。注意!元素必须是字符串类型。 | ||
| defaultType | 0,1,2,,, | 0 | 光标默认移动到第几个选项,从0开始。就是说一进入这个选择页面。 | |
| cancelType | 0,1,2,,, | 0 | 取消选项时,默认选择哪个选项。 |
xxxxxxxxxx11 $gameMessage.setChoices(choices, defaultType, cancelType);
xxxxxxxxxx11 $gameMessage.setChoiceCallback(callback);
示例:
xxxxxxxxxx61$gameMessage.setChoices([ "我","是","选","项"],0,2);2$gameMessage.setChoiceBackground(1);3$gameMessage.setChoicePositionType(1);4$gameMessage.setChoiceCallback(function(n){5 console.log("你选择的是第"+(n+1)+"项!")6});
| 参数 | 参数类型/参数内容 | 默认值 | 说明 |
|---|---|---|---|
| variableId | 正整数 | 所要输入进的变量ID,变量ID可以在编辑器里面直接找到。 | |
| maxDigits | 正整数 | 输入的位数。你可以发现,在事件编辑器里面,这个是最多8位的,但是用代码的话,可以想写几位就写几位。非常自由。 | |
示例:
xxxxxxxxxx11$gameMessage.setNumberInput(6,20);
这个函数可以储存所选物品的物品ID,前提是你必须拥有这个物品。虽然我从来没有用过,但是我想这个功能还是很有用的。
参数
variableId:要把物品ID存入哪个变量中,变量ID可以在编辑器里面直接找到。
itemType:物品的类型,一共有四种数值,而且是从1开始的。真搞不懂官方怎么设计的。
1:普通物品
2:重要物品
3:隐藏物品A
4:隐藏物品B
xxxxxxxxxx11$gameMessage.setItemChoice(5,1);
| 参数 | 参数类型/参数内容 | 默认值 | 说明 |
|---|---|---|---|
| speed | 正数,可以有小数 | 2 | 文字滚动的速度 |
| noFast | true/false | false | 文字是否可以快进,false为可以,true为不可以 |
xxxxxxxxxx11$gameMessage.setScroll(speed,noFast);
示例:
xxxxxxxxxx41$gameMessage.add("内容1");2$gameMessage.add("内容2");3$gameMessage.add("内容3");4$gameMessage.setScroll(2,false);
| 参数 | 参数类型/参数内容 | 默认值 | 说明 |
|---|---|---|---|
| variableId | 正整数,从1开始 | 开关的id | |
| value | true/false | 开关的值 |
xxxxxxxxxx11$gameSwitches.setValue(variableId, value);
同样从1开始
xxxxxxxxxx11$gameSwitches.value(1)
xxxxxxxxxx21$gameVariables.value(1);//查询某个变量的值2$gameVariables.setValue(1,100);//修改某个变量的值
需要传递四个参数
地图ID,表示第几张地图
变量ID
独立开关名称
true还是false
xxxxxxxxxx11$gameSelfSwitches.setValue([4,287,'A'],false)
查询值
xxxxxxxxxx11$gameSelfSwitches.value([4,72,'A'])
xxxxxxxxxx31$gameTimer.start(count);//开始倒计时,count为秒数2$gameTimer.stop();3$gameTimer.seconds();//返回秒数
在脚本中建议使用if else来代替
在脚本中建议使用for循环替代
xxxxxxxxxx31var commonEvent = $dataCommonEvents[公共事件id];2var temp = = new Game_Interpreter(this._depth + 1);3temp.setup(commonEvent.list, eventId);
实际上源代码中,loseGold直接调用了gainGold(-amount),就离谱。
xxxxxxxxxx21$gameParty.gainGold(300);//得到300块钱2$gameParty.loseGold(300);//失去300块钱实际上源代码还是比较复杂的,我这个把源代码提炼精简了一下,你只管放心用。
参数
item:需要传递一个物品对象,可以直接传递$dataItems[1]这种格式。代表第一个物品,注意这些$开头的都是从1开始的。
amount:得到的数量
示例:
xxxxxxxxxx21$gameParty.gainItem($dataItems[1], 30);//得到30个1号物品2$gameParty.loseItem($dataItems[1], 10);//失去10个1号物品
xxxxxxxxxx11 $gameParty.gainItem($dataWeapons[this._params[0]], value, this._params[4]);
xxxxxxxxxx11$gameParty.gainItem($dataArmors[this._params[0]], value, this._params[4]);
注意!如果你队伍中已经有了1号角色,那么再调用增加1号角色的代码将不会有效果(你应该庆幸没有报bug)。
xxxxxxxxxx21$gameParty.addActor(1);//为队伍增加1号角色2$gameParty.removeActor(1);//1号角色离队领队一般是指队伍中第一个玩家角色
xxxxxxxxxx11$gameParty.leader();
注意,这里标号从1开始
xxxxxxxxxx11$gameActors.actor(1)xxxxxxxxxx11$gameParty.allMembers().length
xxxxxxxxxx11$gameParty.highestLevel()
x1Game_Interpreter.prototype.changeHp(target, value, allowDeath)2
3$gameParty.leader().gainHp(-30)
示例:
xxxxxxxxxx11Game_Interpreter.prototype.changeHp($gameParty.leader(),-300,true)
xxxxxxxxxx11$gameParty.leader().gainMp(-30)
xxxxxxxxxx11$gameParty.leader().gainTp(-30)
xxxxxxxxxx21 actor.addState(this._params[3]);2actor.removeState(this._params[3]);xxxxxxxxxx11actor.recoverAll();
xxxxxxxxxx11 actor.changeExp(exp, show);//show代表是否展示升级信息,exp代表经验值
xxxxxxxxxx11 actor.changeLevel(level, show);//同上
xxxxxxxxxx21$gameParty.leader().setName("起的名字");2$gameParty.leader().setName(prompt("自己起一个名字吧") );
xxxxxxxxxx41var actor = $gameActors.actor(this._params[0]);2if (actor) {3 actor.setNickname(this._params[1]);4}
xxxxxxxxxx41var actor = $gameActors.actor(1);2 if (actor) {3 actor.setProfile(this._params[1]);4 }
$gameActors.actor(n)可以获得队伍中某个角色,n为正整数,从1开始。
xxxxxxxxxx371$gameActors.actor(n).agi //角色敏捷2$gameActors.actor(n).atk //角色atk3$gameActors.actor(n).cev //角色会心一击闪躲率4$gameActors.actor(n).cnt //角色反击机率5$gameActors.actor(n).cri //角色会心攻击机率6$gameActors.actor(n).currentExp() //角色当前经验值7$gameActors.actor(n).def //角色防御力8$gameActors.actor(n).eva //角色闪躲率9$gameActors.actor(n).exr //角色经验获得倍率10$gameActors.actor(n).fdr //地板类伤害倍率11$gameActors.actor(n).grd //角色防御倍率12$gameActors.actor(n).hit //角色命中率13$gameActors.actor(n).hp //角色hp14$gameActors.actor(n).hrg //角色hp再生率15$gameActors.actor(n).level //角色lv16$gameActors.actor(n).luk //角色幸运度17$gameActors.actor(n).mat//角色魔法攻击力18$gameActors.actor(n).mcr//角色MP消耗率19$gameActors.actor(n).mdf//角色魔法防御力20$gameActors.actor(n).mdr//角色魔法伤害率(减轻)21$gameActors.actor(n).mev//角色魔法回避率22$gameActors.actor(n).mhp//角色最大HP23$gameActors.actor(n).mmp//角色最大MP24$gameActors.actor(n).mp//角色MP25$gameActors.actor(n).mrf//角色魔法反射率26$gameActors.actor(n).mrg//角色MP再生率27$gameActors.actor(n).nextLevelExp()//角色至下个等级的累计经验值28$gameActors.actor(n).nextRequiredExp()//角色至下个等级的经验值29$gameActors.actor(n).pdr//角色物理伤害率30$gameActors.actor(n).pha//薬の知识31$gameActors.actor(n).rec//角色恢复效果率32$gameActors.actor(n).tcr//角色TP累积率33$gameActors.actor(n).tgr//角色仇恨度(高的容易被怪物瞄准)34$gameActors.actor(n).tp//角色TP35$gameActors.actor(n).trg//角色TP恢复率36$gameActors.actor(n).name()//角色名字37$gameActors.actor(n).actorId()//角色在数据库中的id
第一种就是直接移动,但是画面不会移动。
xxxxxxxxxx11$gamePlayer.setPosition(23,24)第二种就是编辑器里面那个
fadeType:
0:黑
1:白
2:无
xxxxxxxxxx31$gamePlayer.reserveTransfer(mapId, x, y, d, fadeType);2//d代表direction,默认写0.fadetype也写03$gamePlayer.reserveTransfer(3,33,34,0,0)
| 参数 | 参数类型/参数内容 | 默认值 | 说明 |
|---|---|---|---|
| direction | 8:向上 4:向左 6:向右 2:向下 | 2 | 滚动方向,和小键盘是对应的。8,2代表上下,4,6代表左右。 |
| distance | 1 | 距离,代表滚动的格子数 | |
| speed | 1 :1/8速度 2:1/4速度 3:1/2速度 4:标准速度 5:2倍速 6:4倍速 | 4 | 速度,其中速度不一定按照正整数填写,可以自定义小数。参数每+1,速度提升一倍。 |
xxxxxxxxxx11$gameMap.startScroll(direction, distance, speed);
示例:
xxxxxxxxxx11$gameMap.startScroll(2, 1, 4);
n从1开始,n代表事件的id。
xxxxxxxxxx751$gameMap.event(n).moveStraight(2);//向下移动2$gameMap.event(n).moveStraight(4);//向左移动3$gameMap.event(n).setThrough(true); //开启穿透4$gameMap.event(n).setThrough(false); //关闭穿透5$gameMap.event(n).setTransparent(true); //开启透明状态6$gameMap.event(n).setTransparent(false);//关闭透明状态7$gameMap.event(n).turnRandom(); //随机转向8$gameMap.event(n).turnTowardPlayer(); //朝向玩家9$gameMap.event(n).turnAwayFromPlayer(); //背向玩家10$gameMap.event(n).moveTowardPlayer();//朝向玩家移动11$gameMap.event(n).moveAwayFromPlayer();//远离玩家移动12$gameMap.event(n).setMoveFrequency(3); //移动频率13$gamePlayer.setMoveSpeed(4); //角色移动速度 4是默认速度,要注意,这个速板是指数增加的,一旦变了一点点,速度就有极大变化。所以每次增加0.01之类的比较好,如果直接加1速度会太快。14$gameMap.event(n).moveDiagonally(4, 2);//左下移动15$gameMap.event(n).moveDiagonally(6, 2);//右下移动16$gameMap.event(n).moveDiagonally();//左上移动17$gameMap.event(n).moveDiagonally(6, 8);//右上移动18$gameMap.event(n).moveStraight(6);//向右移动19$gameMap.event(n).moveStraight(8);//向上移动20$gameMap.event(n).moveRandom();//随机移动21$gameMap.event(n).moveForward(); //接近玩家22$gameMap.event(n).moveBackward();//远离玩家23$gameMap.event(n).jump(params[0], params[1]); //跳跃24$gameMap.event(n).setDirection(2); //设置朝向下方25$gameMap.event(n).setDirection(4);//设置朝向左方26$gameMap.event(n).setDirection(6);//设置朝向右方27$gameMap.event(n).setDirection(8);//设置朝向上方28$gameMap.event(n).turnRight90();//右转90°29$gameMap.event(n).turnLeft90(); //左转90°30$gameMap.event(n).turn180(); //后转180°31$gameMap.event(n).turnRightOrLeft90();//向左或向右转90°32 this.setWalkAnime(true);33
34switch (command.code) {35 case gc.ROUTE_END:36 this.processRouteEnd();37 break;38
39
40
41 case gc.ROUTE_WAIT:42 this._waitCount = params[0] - 1;43 break;44
45
46 case gc.ROUTE_WALK_ANIME_OFF:47 this.setWalkAnime(false);48 break;49 case gc.ROUTE_STEP_ANIME_ON:50 this.setStepAnime(true);51 break;52 case gc.ROUTE_STEP_ANIME_OFF:53 this.setStepAnime(false);54 break;55 case gc.ROUTE_DIR_FIX_ON:56 this.setDirectionFix(true);57 break;58 case gc.ROUTE_DIR_FIX_OFF:59 this.setDirectionFix(false);60 break;61
62 case gc.ROUTE_CHANGE_IMAGE:63 this.setImage(params[0], params[1]);64 break;65 case gc.ROUTE_CHANGE_OPACITY:66 this.setOpacity(params[0]);67 break;68 case gc.ROUTE_CHANGE_BLEND_MODE:69 this.setBlendMode(params[0]);70 break;71 case gc.ROUTE_PLAY_SE:72 AudioManager.playSe(params[0]);73 break;74
75 }
在这里特指地图上那个人物的动画。要和角色区分开。角色是记录角色数据信息的,而人物则反映了在画面上的移动速度、动画等信息。
xxxxxxxxxx11$gamePlayer.setTransparent(true)//开启透明
xxxxxxxxxx21$gamePlayer.showFollowers();2$gamePlayer.hideFollowers();
xxxxxxxxxx21$gamePlayer.gatherFollowers();2this.setWaitMode(‘gather’);
xxxxxxxxxx11$gamePlayer.requestAnimation(1);
xxxxxxxxxx11$gamePlayer.requestBalloon(1) //显示惊讶
要注意理论上来说这个id可以无限大1
有多大取决于系统中Ballon.png有多高,默认720像素,每一个小方块48像素。默认有10个,其图片还预留了5个扩展位置,开发者可以自己画,如果不够了只需要向下拓展即可。
例如多扩展48*5像素,那么就可以多画5个气泡,最多可以访问到20号气泡。
xxxxxxxxxx11$gameMap.eraseEvent(this._eventId);
注意!这个设置不会使画面一起移动。如果想要画面也一起移动,建议使用移动中的”场所移动“。
xxxxxxxxxx11$gamePlayer.setPosition(3,6)
MV中朝向被定义为4个数字
左:4
右:6
上:8
下:2
其实,,这个和小键盘的方向是一一对应的。
xxxxxxxxxx11$gamePlayer.direction() //查看队伍方向
| 参数 | 参数类型/参数内容 | 默认值 | 说明 |
|---|---|---|---|
| pictureId | 编号 | ||
| name | 图像名称 | ||
| origin | 0:左上 1:中心 | 0 | 原点的位置 |
| x | 0 | ||
| y | 0 | ||
| scaleX | 100 | 宽度缩放 | |
| scaleY | 100 | 高度缩放 | |
| opacity | 0到255 | 255 | 透明度 |
| blendMode | 0:正常 1:叠加 2:正片叠底 3:滤色 | 0 | 合成模式 |
xxxxxxxxxx11$gameScreen.showPicture(pictureId, name, origin, x, y,scaleX, scaleY, opacity, blendMode)
例如:
xxxxxxxxxx11$gameScreen.showPicture(1,"图片名称", 0, 0, 0,100, 100, 255, 0)
参数如上
xxxxxxxxxx11$gameScreen.movePicture(pictureId, origin, x, y, scaleX,scaleY, opacity, blendMode, duration);
xxxxxxxxxx11$gameScreen.rotatePicture(this._params[0], this._params[1]);
xxxxxxxxxx11$gameScreen.tintPicture(this._params[0], this._params[1], this._params[2]);
xxxxxxxxxx11$gameScreen.erasePicture(pictureId);
xxxxxxxxxx11$gameScreen.clearPictures();
要注意,这个脚本需要写在事件中
xxxxxxxxxx11this.wait(duration);
xxxxxxxxxx11$gameScreen.startFadeOut(duration) //淡出
xxxxxxxxxx11$gameScreen.startFadeIn(duration) //淡入
xxxxxxxxxx11$gameScreen.startTint(tone, duration);这个tone同样是一个颜色。数组各项分别为RGB+灰度。
xxxxxxxxxx101//下面是官方的预设值:2$gameScreen.startTint([0, 0, 0, 0], 60); //正常3$gameScreen.startTint([-68, -68, -68, 0], 60); //黑暗4$gameScreen.startTint([34, -34, -68, 170], 60); //茶色5$gameScreen.startTint([68, -34, -34, 0], 60); //黄昏6$gameScreen.startTint([-68, -68, 0, 68], 60); //夜晚7
8//下面是我自己总结的9$gameScreen.startTint([50, 50, 50, 0], 60); //正午10$gameScreen.startTint([-120, -100, 0, 68], 60);//深夜
xxxxxxxxxx11$gameScreen.startFlash(color, duration);颜色使用的是RGB+强度,调用时使用数组
xxxxxxxxxx11$gameScreen.startFlash([255, 0, 0, 128], 8);
默认5,5,60
xxxxxxxxxx11$gameScreen.startShake(power, speed, duration);
| 默认值 | |||
|---|---|---|---|
| type | none rain storm snow | none | 天气类型 |
| power | 5 | 强度 | |
| duration | 60 | 持续时间,单位为帧数。 |
xxxxxxxxxx11$gameScreen.changeWeather(type, power, duration);
示例:
xxxxxxxxxx11$gameScreen.changeWeather("storm", 10, 60);
xxxxxxxxxx11$gameScreen.weatherType()//查看天气类型
注意,如果之前已经有bgm的话,这个会把之前的给挤掉。
xxxxxxxxxx71var bgm = new Object();2bgm.name = "对峙";//bgm的名称3bgm.volume = 100;//响度4bgm.pitch = 100;//音调5bgm.pan = 0;//偏移6AudioManager.playBgm(bgm);7//AudioManager.playBgm(bgm,pos);//pos可以缺省参数为秒数
xxxxxxxxxx11AudioManager.fadeOutBgm(duration);xxxxxxxxxx11$gameSystem.saveBgm();
xxxxxxxxxx11$gameSystem.replayBgm();
xxxxxxxxxx11 AudioManager.playBgs(this._params[0]);
xxxxxxxxxx11AudioManager.fadeOutBgs(this._params[0]);
xxxxxxxxxx61var me = new Object();2se.name = Inn";//me的名称3se.volume = 100;//响度4se.pitch = 100;//音调5se.pan = 0;//偏移6AudioManager.playMe(me);
xxxxxxxxxx61var se = new Object();2se.name = "Bell3";//se的名称3se.volume = 100;//响度4se.pitch = 100;//音调5se.pan = 0;//偏移6AudioManager.playSe(se);//播放音效经过我的感觉,一些音名对照表如下。
| C | D | E | F | G | A | B |
|---|---|---|---|---|---|---|
| 40 | 45 | 50 | 52 | 58 | 65 | 75 |
xxxxxxxxxx11AudioManager.stopSe();
xxxxxxxxxx11Graphics.playVideo('movies/PV.webm');
这个所谓的系统,并不是说windows系统,而是说MV数据库里面那个系统。这个音效的顺序和MV系统里面的音保持一致。
xxxxxxxxxx241SoundManager.playCursor()//光标2SoundManager.playOk()//确定3SoundManager.playCancel()//取消4SoundManager.playBuzzer()//无效5SoundManager.playEquip()//装备6SoundManager.playSave()//存档7SoundManager.playLoad() //读档8SoundManager.playBattleStart() //战斗开始9SoundManager.playEscape() //逃跑10SoundManager.playEnemyAttack() //敌人攻击 11SoundManager.playEnemyDamage() //敌人受伤12SoundManager.playEnemyCollapse() //敌人消失13SoundManager.playBossCollapse1() //Boss消失114SoundManager.playBossCollapse2() //Boss消失215SoundManager.playActorDamage() //角色受伤16SoundManager.playActorCollapse() //角色无法战斗 17SoundManager.playRecovery() //恢复18SoundManager.playMiss() //未命中19SoundManager.playEvasion() //回避20SoundManager.playMagicEvasion() //魔法回避21SoundManager.playReflection() //魔法反射 22SoundManager.playShop() //商店23SoundManager.playUseItem() //使用物品24SoundManager.playUseSkill() //使用技能
troopId:敌群id
xxxxxxxxxx11BattleManager.setup(troopId, true/false, true/false);
xxxxxxxxxx11SceneManager.push(Scene_Shop);
xxxxxxxxxx11SceneManager.push(Scene_Name);
xxxxxxxxxx11SceneManager.push(Scene_Menu);xxxxxxxxxx11SceneManager.push(Scene_Save);
xxxxxxxxxx11SceneManager.goto(Scene_Gameover);
xxxxxxxxxx11SceneManager.goto(Scene_Title);
xxxxxxxxxx11 $gameSystem.setBattleBgm(this._params[0]);
xxxxxxxxxx11 $gameSystem.setVictoryMe(this._params[0]);
xxxxxxxxxx11$gameSystem.setDefeatMe(this._params[0]);
xxxxxxxxxx41var vehicle = $gameMap.vehicle(this._params[0]);2if (vehicle) {3 vehicle.setBgm(this._params[1]);4}
xxxxxxxxxx21$gameSystem.disableSave();2$gameSystem.enableSave();
xxxxxxxxxx21$gameSystem.disableMenu();2$gameSystem.enableMenu();
xxxxxxxxxx21$gameSystem.disableEncounter();2$gameSystem.enableEncounter();
xxxxxxxxxx21$gameSystem.disableFormation();2$gameSystem.enableFormation();
value是一个长度为4 的数组,4个元素分别是rgba
xxxxxxxxxx11$gameSystem.setWindowTone(value);
例如:
xxxxxxxxxx11$gameSystem.setWindowTone([200,100,100,0]);//设置窗口rgb为200,100,100
xxxxxxxxxx31$gameActors.actor(actorId).setCharacterImage(characterName, characterIndex);2$gameActors.actor(actorId).setFaceImage(faceName, faceIndex):3$gameActors.actor(actorId).setBattlerImage(battlerName);
xxxxxxxxxx11 $gameMap.vehicle(vehicleId).setImage(name, index);
xxxxxxxxxx21$gameSystem.playtimeText() //游戏时间,用时分秒表示2$gameSystem.playtime() //游戏时间,用秒表示xxxxxxxxxx11Graphics.showFps();
这个是直接暴力关闭窗口,不会有任何弹窗!!!慎用!
xxxxxxxxxx11window.close()
xxxxxxxxxx21$gameMap.enableNameDisplay();//启用2$gameMap.disableNameDisplay();//禁用
xxxxxxxxxx21$gameMap.changeParallax(this._params[0], this._params[1],2 this._params[2], this._params[3], this._params[4]);
变量
xxxxxxxxxx11
xxxxxxxxxx21$gameMap.height()2$gameMap.width()
xxxxxxxxxx11$gameTroop.members()[enemyIndex].gainHp(value);xxxxxxxxxx11$gameTroop.members()[enemyIndex].gainMp(value);
xxxxxxxxxx11$gameTroop.members()[enemyIndex].gainTp(value);
xxxxxxxxxx21$gameTroop.members()[enemyIndex].addState(n);2$gameTroop.members()[enemyIndex].removeState(n);
xxxxxxxxxx11$gameTroop.members()[enemyIndex].recoverAll();
xxxxxxxxxx11$gameTroop.members()[enemyIndex].appear();
xxxxxxxxxx11$gameTroop.members()[enemyIndex].transform(n);
xxxxxxxxxx11 $gameTroop.members()[enemyIndex].startAnimation(animationId, true/false, delayN);
我方强制动作
xxxxxxxxxx21$gameParty.members()[index].forceAction(skillId, targetIndex);2BattleManager.forceAction($gameParty.members()[index]);
敌人强制动作
xxxxxxxxxx21$gameTroop.members()[index].forceAction(skillId, targetIndex);2BattleManager.forceAction($gameTroop.members()[index]);
xxxxxxxxxx11BattleManager.abort();
xxxxxxxxxx11$gameTroop.enemyNames()xxxxxxxxxx11$gameTroop._enemies[0]是否处于战斗状态
xxxxxxxxxx11$gameTroop._inBattle
请使用eval()代替
xxxxxxxxxx101
2function 调用插件指令(插件指令){3 var args =插件指令.split(" ");4 var command = args.shift();5 Game_Interpreter.prototype.pluginCommand(command, args);6}7//使用时,直接把需要的插件指令复制到形式参数里面就可以了8//比如说9调用插件指令("我的插件 参数")10
直接可以用事件来播放动画,动画会作用在其身上。
里面的参数只需要传递动画的编号即可
xxxxxxxxxx11$gameMap._events[11].requestAnimation(1)
xxxxxxxxxx11$gameMap.events()
这个id可以在编辑器中,点开某个事件,查看其左上角得到。id从1开始。
xxxxxxxxxx11$gameMap.event(1)
xxxxxxxxxx71//这个方法可以直接获得注释的内容2$dataMap.events[eventID].note3
4//如果注释是以对象形式写的,那么可以用meta属性进行访问5//<name:莲华><age:13>6$dataMap.events[eventID].meta.name7$dataMap.events[eventID].meta.age如果指定的位置没有事件,那么返回0。
xxxxxxxxxx11$gameMap.eventIdXy(x,y);可以直接用脚本来开启事件
xxxxxxxxxx11$gameMap.event(1).start()在地图上,直接在对象的事件指令里面创建一个脚本,里面写上下面这个,就可以打印出该事件对象。
xxxxxxxxxx11console.log($gameMap._events[this._eventId])
如果不是写在事件编辑器的话,可以指定事件ID来进行访问。
xxxxxxxxxx11console.log($gameMap._events[11])
也可以直接根据坐标来访问
xxxxxxxxxx11$gameMap.eventsXy(31, 33)
标准速度是4,也就是人物的速度。
xxxxxxxxxx11$gameMap._events[11]._moveSpeed
xxxxxxxxxx11$gameMap.event(1).isNearThePlayer()
这个函数也比较特殊,并不是只要你移动了鼠标就能被检测到,而是说你必须一直按着并且移动才会true。这个其实是为触摸板设计的。
xxxxxxxxxx11TouchInput.isMoved() //是否按下鼠标左键同时移动了鼠标
xxxxxxxxxx11TouchInput.isPressed() //鼠标左键是否正在被按下
xxxxxxxxxx11TouchInput.isTriggered() //鼠标左键刚刚是否按下xxxxxxxxxx21TouchInput.isRepeated() //鼠标左键是否连续点击,或者一直处于按下状态2TouchInput.isLongPressed() //鼠标左键是否一直按下要注意的就是这个isRepeated()和isLongPressed(),这两个比较像,但是还是有很大区别的。如果你鼠标一直狂点,那么isRepeated()会返回true,但是isLongPressed()不会。而长按鼠标左键,两个都会返回true。
xxxxxxxxxx11TouchInput.isReleased() //鼠标左键是否释放xxxxxxxxxx11TouchInput.isCancelled() //鼠标右键是否点击
xxxxxxxxxx21TouchInput.x2TouchInput.y
xxxxxxxxxx311Input.keyMapper = {2 9: 'tab', 3 13: 'ok', 4 16: 'shift', 5 17: 'control', 6 18: 'control', 7 27: 'escape', 8 32: 'ok', 9 33: 'pageup', 10 34: 'pagedown', 11 37: 'left', 12 38: 'up', 13 39: 'right', 14 40: 'down', 15 45: 'escape', 16 81: 'pageup', 17 87: 'pagedown', 18 88: 'escape', 19 90: 'ok', 20 96: 'escape', 21 98: 'down', 22 100: 'left', 23 102: 'right', 24 104: 'up', 25 120: 'debug', 26 //WASD的按键27 65: 'left', // 左箭头键28 87: 'up', // 上箭头键29 68: 'right', // 右箭头键30 83: 'down' // 下箭头键31};
下面这些函数要传递一个参数,也就是要检测的按键的名字,刚刚那个映射表里面都写了,直接复制就行。(注意把引号也带上)
xxxxxxxxxx41Input.isPressed('ok') //按键是否正在被按下2Input.isTriggered() //按键刚刚是否按下3Input.isRepeated() //按键是否连续点击,或者一直处于按下状态4Input.isLongPressed() //按键是否一直按下这个和上面的鼠标一模一样,不多做解释。
-1:载入配置文件
0:载入第一个文件
xxxxxxxxxx11StorageManager.load(savefileId);//返回一个json文件xxxxxxxxxx11DataManager.loadGlobalInfo();//返回一个数组,从1开始。
xxxxxxxxxx11$dataWeapons[$gameParty.leader()._equips[0]._itemId].name
xxxxxxxxxx11$gameParty.leader()._equips//获取领队的装备数据这个会返回一个数组,里面有5个元素,分别对应游戏里面的装备信息
0:武器
1:盾牌
2:头部
3:身体
4:装饰品
但是这个的信息非常简陋,里面只存放了武器和装备的编号而已,并没有真正地存放物品信息。所以如果想获取真正的数据,还得去访问$dataWeapons。
xxxxxxxxxx11$dataWeapons[$gameParty.leader()._equips[0]._itemId]这样子,先获取玩家的装备编号,再进行查询。然后就好了。
这个$dataWeapons的数据如下:
| 属性 | 说明 |
|---|---|
| animationId | 动画编号 |
| description | 说明 |
| etypeId | |
| iconIndex | 图标编号 |
| id | 武器的编号 |
| maxItem | 最大持有量 |
| meta | 注释的JSON |
| name | 武器名字 |
| note | 备注 |
| params | 武器数据的数组,从0到7分别是[0:最大HP,1:最大MP,2:攻击力,3:防御力,4:魔法攻击,5:魔法防御,6:敏捷,7:幸运] |
| price | 价格 |
| traits | 特性,比如追加能力什么的 |
| wtypeId | 武器类型的编号 |
另外,装备里面的备注是可以直接用对象的形式访问的。
xxxxxxxxxx11$dataWeapons[$gameParty.leader()._equips[0]._itemId].meta.你写的标签属性
xxxxxxxxxx31Graphics.showFps()2Graphics.hideFps()3
xxxxxxxxxx61Utils.isNwjs() //是否是nwjs环境2Utils.isNwjs() && process.platform === 'win32' //是否为windows系统3Utils.isNwjs() && process.platform === 'darwin' //是否为mac系统4Utils.isMobileDevice() //是否为手机设备5Utils.isMobileSafari() //是否为手机端Safari6Utils.isAndroidChrome() //是否为安卓端chrome
每个配置文件中必须要提供以下属性:
属性:应用起始页
String - 如 index.html也可以是 .js文件或url,该文件与 package.json统计目录.
xxxxxxxxxx11"main": "index.html",
属性:应用名称,应确保该字段内容全局唯一性
String - 名称由数字 , 小写字母 , "." , "_"或者"-"组成,其它内容会被忽略.
控制NW.js应提供的功能及如何打开主窗口.
属性:是否支持Node
Boolean - false时将禁用Node.
属性:指定Node.js脚本文件路径 . 并且它将在加载DOM窗口之前启动Node环境时执行
String - Node.js脚本文件路径
属性:指定主机域名
String - 在 chrome-extension://协议URL指定主机域名 . WEB引擎将是应用和同一域名的网站之间共享cookie
属性:是否以单实例运行
Boolean - true即单实例运行, false则允许应用多开,默认 true
属性:后台脚本
String - 应用启动时执行的后台脚本 .
属性:窗体样式控制
Object - 详见窗体子字段章节
属性:WebKit特性控制
Object - 详见WebKit子字段章节
属性:重写应用请求页面中的
User-Agent信息
String - 重写的 User-Agent信息
以下变量内容可以动态设置 User-Agent内容:
%name: 替换配置文件中的name字段 .
%ver: 替换配置文件中的version字段 .
%nwver: 替换NW.js版本 .
%webkit_ver: 替换WebKit引擎版本 .
%osinfo: 替换系统以及CPU信息 .
属性:从远程页面启用Node
Array 或 String - 数组中的各项均需遵循在Chrome扩展中使用的匹配模式
匹配模式本质上为URL , 由 http, https, file , ftp或者 '*'开始 . 其中 '*'代表匹配所有URL . 每个匹配模式由三部分组成:
基础语法:
xxxxxxxxxx41<url-pattern> := <scheme>://<host><path>2<scheme> := '*' | 'http' | 'https' | 'file' | 'ftp'3<host> := '*' | '*.' <any char except '/' and '*'>+4<path> := '/' <any chars>属性:分发应用时自定义chromium命令行参数至应用
String - 指定的chromium命令行参数
例如:想要禁用GPU加速视频显示,只需添加添加参数 "chromium-args" : "--disable-accelerated-video".
如果添加多个参数,则使用空格进行分割,该字段也可使用单引号括起标记.命令行详细信息,请参阅 Command-Line-Options
属性:应用崩溃时,崩溃转存报告将被发送到设定的服务器
String - 崩溃报告服务器的URL
与Chromium浏览器发送方式相同,发送具有 multipart/form-data内容的HTTP POST请求. 理论上来讲, 任意 breakpad/crashpad 都可以处理该请求,因为 breakpad/crashpad 与NW相仿,. 请参阅 简单服务器的小案例或使用现有的simple-breakpad-server.
该请求至少包含以下字段:
prod - 配置文件中的 name 属性
ver - 配置文件中的 version 属性
upload_file_minidump - minidump文件的二进制内容
switch-n - 崩溃过程的命令行切换开关,每个切换有多个字段,其中 n从1起始.
属性:指定JS引擎(V8)可用特性
String - 可用特性如打开协调代理( Harmony Proxies)以及集合( Collections):
xxxxxxxxxx51{2 "name": "nw-demo",3 "main": "index.html",4 "js-flags": "--harmony_proxies --harmony_collections"5}属性:执行JavaScript代码
String -相对于应用程序路径的本地文件名,期望执行的JavaScript文件
inject_js_start: CSS文件执行之后 , 其他DOM或脚本运行之前 , 执行的JavaScript代码 .
inject_js_end: 页面document对象加载之后 , 触发 onload之前 , 执行的JavaScript代码 . 主要作为新窗口中 Window.open()的参数执行JavaScript代码 .
属性:证书作为附加可用的根证书使用 , 允许连接自签名证书或者CA签发机构颁发证书的服务
Array - 数多个PEM编码的证书组成的数组 , 例如 "-----BEGIN CERTIFICATE-----\n...certificate data...\n-----END CERTIFICATE-----\n"
属性:Mb为单位的DOM存数限制数量
Integer - 建议设置为期望值的两倍
属性:窗口子字段默认情况被继承到使用
window.open()或<a target="_blank">打开的子窗口 .未继承子字段将被设置为打开窗口时的默认值
列表如下:
fullscreen -> false
kiosk -> false
position -> null
resizable -> true
show -> true
所有窗口子字段可以使用new-win-policy事件重写 .
属性:内含窗口尺寸与位置的状态的窗口ID,打开同ID的窗口时会还原该状态
String - 窗口ID,细节请另见Chrome应用文档
属性:NW.js创建的窗口标题 . 在应用启动时显示的标题信息
String -标题
属性:主窗口初始宽高
Integer - 宽高
属性:是否显示导航栏中的工具条
Boolean - true显示, false不显示
属性:窗口图标
String - 图标路径
属性:窗口位置
String - 默认 null(不固定) , center(屏幕居中) , mouse(鼠标所在位置)
属性:窗口最小宽高
Integer - 最小宽高值
属性:窗口最大宽高
Integer - 最大宽高值
属性:X11环境下,作为桌面背景显示
Boolean - true显示, false不显示
属性:是否可调整窗口大小
Boolean - true允许, false不允许
【注意】 ,在OS X上将该属性设置为 false,并将frame设置为 true,用户还是可以将窗口全屏显示。只有将全屏也设置为 false才可禁用全屏控件。
属性:是否允许窗口始终置顶(在其余窗口之上)
Boolean - true允许, false不允许
属性:支持多工作区的系统(如Mac & Linux)中,将窗口同时显示在所有工作区中
Boolean - true允许, false不允许
属性:是否允许窗口全屏
Boolean - true允许, false不允许
【注意】 ,窗体和全屏框架应当一致,窗口设置为 false时,则全屏框架不应设为 true,避免窗体将阻止鼠标获取屏幕边缘.
属性:是否允许显示在任务栏或停靠栏中
Boolean - true允许, false不允许,默认 true.
属性:窗口是否为框架
Boolean - 设为 false时即无框窗口.
【注意】 ,窗体和全屏框架应当一致,窗口设置为 false时,则全屏框架不应设为 true,避免窗体将阻止鼠标获取屏幕边缘.
属性:启动时是否显示应用
Boolean - true显示, false不显示
属性:是否使用
Kiosk模式(该模式即应用将全屏并阻止用户离开应用,比如常见的公共触摸屏演示)
Boolean - true使用, false不使用
属性:窗口是否透明
Boolean - true允许, false不允许,默认 false.
窗口的透明度由CSS中的背景透明值控制,
使用命令行参数 --disable-transparency 可完全禁止透明功能.
使用命令行参数 --disable-gpu 禁用GPU后,可实现透明窗体的穿透点击
属性:是否启用两指缩放功能
Boolean - true允许, false不允许,默认 false.
属性:是否可加载扩展插件,比如Flash插件
Boolean - true允许, false不允许,默认 true.
关于package.json的更多字段,请参考Packages/1.0
属性:配置的描述说明,以
.结束
属性:应用版本信息
属性:维护成员
xxxxxxxxxx51"maintainers":[ {2 "name": "Bill Bloggs",3 "email": "billblogs@bblogmedia.com",4 " web": "http://www.bblogmedia.com",5}]属性:贡献者,与维护成员格式一致,但首个应为作者
属性:提交错误的网址,如mail或http地址
属性:许可证列表
xxxxxxxxxx61"licenses": [2{3"type": "GPLv2",4"url": "http://www.example.com/licenses/gpl.html",5}6]dependencies
属性:必要依赖,组的顺序非常重要,较前条目具有较高优先级.
xxxxxxxxxx71"dependencies": {2 "webkit": "1.2",3 "ssl": {4 "gnutls": ["1.0", "2.0"],5 "openssl": "0.9.8",6 },7}属性:网站URL地址
xxxxxxxxxx831{ 2 /**指定程序的起始页面。*/ 3 "main": "index.html", 4 5 /**字符串必须是小写字母或者数字,可以包含.或者_或者-不允许带空格。name必须全局唯一。*/ 6 "name": "demo", 7 8 /**程序描述*/ 9 "description": "demo app of node-webkit", 10 11 /**程序版本号*/ 12 "version": "0.1.0", 13 14 /**关键字*/ 15 "keywords": ["demo","node-webkit"], 16 17 /**bool值,如果设置为false,将禁用webkit的node支持。*/ 18 "nodejs": true, 19 /** 20 * 指定一个node.js文件,当程序启动时,该文件会被运行,启动时间要早于node-webkit加载html的时间。 21 * 它在node上下文中运行,可以用它来实现类似后台线程的功能。 22 * (不需要可注释不用) 23 */ 24 "node-main": "js/node.js", 25 26 27 /** 28 * bool值。默认情况下,如果将node-webkit程序打包发布,那么只能启动一个该应用的实例。 29 * 如果你希望允许同时启动多个实例,将该值设置为false。 30 */ 31 "single-instance": true, 32 33 /**窗口属性设置 */ 34 "window": { 35 /**字符串,设置默认title。*/ 36 "title": "demo", 37 /**窗口的icon。*/ 38 "icon": "link.png", 39 /**bool值。是否显示导航栏。*/ 40 "toolbar": false, 41 /**bool值。是否允许调整窗口大小。*/ 42 "resizable": true, 43 /**是否全屏*/ 44 "fullscreen": false, 45 /**是否在win任务栏显示图标*/ 46 "show_in_taskbar": true, 47 /**bool值。如果设置为false,程序将无边框显示。*/ 48 "frame": true, 49 /**字符串。窗口打开时的位置,可以设置为“null”、“center”或者“mouse”。*/ 50 "position": "center", 51 /**主窗口的的宽度。*/ 52 "width": 800, 53 /**主窗口的的高度。*/ 54 "height": 670, 55 /**窗口的最小宽度。*/ 56 "min_width": 400, 57 /**窗口的最小高度。*/ 58 "min_height": 335, 59 /**窗口显示的最大宽度,可不设。*/ 60 "max_width": 800, 61 /**窗口显示的最大高度,可不设。*/ 62 "max_height": 670, 63 /**bool值,如果设置为false,启动时窗口不可见。*/ 64 "show": true, 65 /**是否在任务栏显示图标。*/ 66 "show_in_taskbar":true, 67 /** 68 * bool值。是否使用kiosk模式。如果使用kiosk模式, 69 * 应用程序将全屏显示,并且阻止用户离开应用。 70 * */ 71 "kiosk": false 72 }, 73 74 /**webkit设置*/ 75 "webkit": { 76 /**bool值,是否加载插件,如flash,默认值为false。*/ 77 "plugin": true, 78 /**bool值,是否加载Java applets,默认为false。*/ 79 "java": false, 80 /**bool值,是否启用页面缓存,默认为false。*/ 81 "page-cache": false 82 } 83}
xxxxxxxxxx131{2 "name": "",3 "main": "index.html",4 "js-flags": "--expose-gc",5 "window": {6 "title": "",7 "toolbar": false,8 "width": 816,9 "height": 624,10 "icon": "icon/icon.png"11 }12}13
查看nw版本
xxxxxxxxxx11nw.process.versions.nwxxxxxxxxxx151#全局安装nw-gyp2npm install -g nw-gyp3#设置目标NW.js版本4set npm_config_target=0.31.45#设置构建架构,ia32或x64,win10, osx为x64操作系统6set npm_config_arch=x647set npm_config_runtime=node-webkit8set npm_config_build_from_source=true9set npm_config_node_gyp=C:\Users\NALA\AppData\Roaming\npm\node_modules\nw-gyp\bin\nw-gyp.js10 11#win10下还要设置python路径:12set PYTHON=C:\Users\NALA\.windows-build-tools\python27\python.exe13 14最后 npm install —msvs_version=2015•安装编译不成功,就多试几次,删除package-lock.json15
Window是DOM中 顶层window对象的包装类 . 可扩展操作以及接收窗口事件 .每个
Window都是EventEmitter类实例 , 使用Window.on(...)可响应窗口事件 .
有两种等价写法
xxxxxxxxxx21var win = require('nw.gui').Window.get();2var win2 = nw.Window.get();但是实际上win===win2,因为窗口是一个非常重要的对象,所以这个是一个单例,不管是谁,获取到的对象都是一个。
一共三个参数,其中,第二个是配置信息,详情参考配置中的窗口子字段。
xxxxxxxxxx61nw.Window.open('test.html', {}, function (new_win) {2 //新窗口创建时的回调函数3 new_win.on('focus', function () {4 console.log('点击了新窗口!');5 });6});
窗口相对于显示器的位置
xxxxxxxxxx21nw.Window.get().x2nw.Window.get().yxxxxxxxxxx21nw.Window.get().moveTo(x, y)//移动窗口到指定位置,将窗口的左上角移动到指定的坐标2nw.Window.get().moveBy(x, y)//移动窗口到相对于当前窗口左上角的横纵偏移,比如窗口上移10px
position String -指定的窗口位置,可选值: null(不固定) , center(屏幕居中) , mouse(鼠标所在位置)
xxxxxxxxxx11nw.Window.get().setPosition('mouse')//移动窗口到鼠标所在位置
xxxxxxxxxx21nw.Window.get().width2nw.Window.get().heightxxxxxxxxxx21nw.Window.get().resizeTo(width, height)//重设窗口尺寸为 width 和 height2nw.Window.get().resizeBy(width, height)//调整窗口尺寸为相对于当前窗口尺寸的width 和 height,比如窗口加宽10pxxxxxxxxxxx21nw.Window.get().setMaximumSize(width, height)//设置窗口的最大宽高2nw.Window.get().setMinimumSize(width, height)//设置窗口的最小宽高xxxxxxxxxx11nw.Window.get().setResizable(true)
就是让窗口保持最前面,
xxxxxxxxxx11nw.Window.get().focus()
xxxxxxxxxx11nw.Window.get().setAlwaysOnTop(false) //是否允许窗口总是置顶(在其余窗口上面)
xxxxxxxxxx21require('nw.gui').Window.get().showDevTools();//打开2require('nw.gui').Window.get().closeDevTools();//关闭
xxxxxxxxxx11nw.Window.get().isDevToolsOpen()
xxxxxxxxxx101nw.Window.get().enterFullscreen();//全屏2nw.Window.get().leaveFullscreen() //退出全屏3
4nw.Window.get().minimize();//最小化5
6nw.Window.get().maximize()//最大化7用途:Linux和Window中最大化窗口 , Mac中放大窗口8
9win.minimize()10用途:Windows/Mac中最小化窗口 , Linux中图标化窗口xxxxxxxxxx11nw.Window.get().hide()
xxxxxxxxxx81// 监听最小化事件2nw.Window.get().on('minimize', function() {3 console.log('最小化了!');4});5
6// 移除最小化监听事件7nw.Window.get().removeAllListeners('minimize');8
xxxxxxxxxx71// 监听最大化事件2nw.Window.get().on('maximize', function() {3 console.log('最大化了!');4});5
6// 移除最大化监听事件7nw.Window.get().removeAllListeners('maximize');
xxxxxxxxxx61nw.Window.get().on('close', function () {2 this.hide(); // 关闭窗口3 this.close(true); // 真正关闭窗口进程,注意一旦里面写false,就会无限循环4});5
6nw.Window.get().removeAllListeners('close');
xxxxxxxxxx61//获取焦点事件2nw.Window.get().on('focus', function () {3
4});5
6nw.Window.get().removeAllListeners('focus');
xxxxxxxxxx61//失去焦点事件2nw.Window.get().on('blur', function () {3
4});5
6nw.Window.get().removeAllListeners('blur');
xxxxxxxxxx61//失去焦点事件2nw.Window.get().on('enter-fullscreen', function () {3
4});5
6nw.Window.get().removeAllListeners('enter-fullscreen');
xxxxxxxxxx81//阻止游戏关闭2nw.Window.get().on('devtools-closed', function () {3 this.hide(); // 关闭窗口4 this.close(true); // 真正关闭窗口进程,注意一旦里面写false,就会无限循环5});6
7
8nw.Window.get().removeAllListeners('devtools-closed');
xxxxxxxxxx141var option = {2 key : "Ctrl+Shift+A",3 active : function() {4 console.log("发现快捷键: " + this.key + " 被激活!"); 5 },6 failed : function(msg) {7 //报错信息8 console.log(msg);9 }10};11
12var shortcut = new nw.Shortcut(option);13nw.App.registerGlobalHotKey(shortcut);14
下面是一些支持的快捷键
字母表的: A-Z
数字: 0-9
功能键: F1-F24
Comma
Period
Tab
Home / End / PageUp / PageDown / Insert / Delete
Up / Down / Left / Right
MediaNextTrack / MediaPlayPause / MediaPrevTrack / MediaStop
Comma or ,
Period or .
Tab or \t
Backquote or ```
Enter or \n
Minus or -
Equal or =
Backslash or \
Semicolon or ;
Quote or '
BracketLeft or [
BracketRight or [
Escape
xxxxxxxxxx81// 默认浏览器中打开指定URL2nw.Shell.openExternal('https://github.com/nwjs/nw.js');3
4// 默认编辑器中打开指定文件。5nw.Shell.openItem('test.txt');6
7// 文件管理器中显示指定文件所在目录。8nw.Shell.showItemInFolder('test.txt');
xxxxxxxxxx121// 获取系统中剪贴板对象2var clipboard = nw.Clipboard.get();3
4// 剪贴板中读取信息5var text = clipboard.get('text');6console.log(text);7
8// 向剪贴板写入9clipboard.set('I love NW.js :)', 'text');10
11// 清空剪贴板12clipboard.clear();
xxxxxxxxxx11global.a =1;
xxxxxxxxxx391
2
3 窗体名.prototype.饥饿条颜色1= function() {4 return this.textColor(4);5 };6 窗体名.prototype.饥饿条颜色2= function() {7 return this.textColor(5);8 };9 窗体名.prototype.饥饿条长度比例= function(饥饿度,满饥饿度) {10 return 饥饿度 / 满饥饿度;11 };12
13 //自定义内容,例如,当饥饿度比值低于某个值的时候,会显示红色14 窗体名.prototype.饥饿文字颜色 = function(饥饿度比值)15 {16 if(饥饿度比值<0.1)17 return this.textColor(10);18 else19 return this.textColor(0);20 }21
22
23 窗体名.prototype.画饥饿条 = function(actor, x, y, width)24 {25 var 当前饥饿= 2026 var 最大饥饿 =100 27 width = width || 186;28 var color1 = this.饥饿条颜色1();29 var color2 = this.饥饿条颜色2();30 var 饥饿度比值 = this.饥饿条长度比例(当前饥饿,最大饥饿)31 this.drawGauge(x, y, width, 饥饿度比值, color1, color2);//这个是用来画条的。比值就控制的是其长度。32
33 this.changeTextColor(this.textColor(0));//文字颜色34 this.drawText("饥饿度", x, y, 44);//绘制文字的内容和位置35 this.drawCurrentAndMax(当前饥饿, 最大饥饿, x, y, width,36 this.饥饿文字颜色(饥饿度比值), this.normalColor());//绘制具体的数值。例如饥饿度是20,中国就会显示2037 38 }39
就是游戏一进去那个场景,有开始游戏,继续游戏那个。
xxxxxxxxxx251Window_TitleCommand.prototype.makeCommandList = function () {2 this.addCommand(TextManager.newGame, 'newGame');3 this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());4 this.addCommand(TextManager.options, 'options');5
6 this.addCommand("测试", 'test');//第一个是按钮名称,第二个是绑定的方法名7};8
9
10//重写窗体11Scene_Title.prototype.createCommandWindow = function () {12 this._commandWindow = new Window_TitleCommand();13 this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this));14 this._commandWindow.setHandler('continue', this.commandContinue.bind(this));15 this._commandWindow.setHandler('options', this.commandOptions.bind(this));16 17 //test方法在这里写,以此类推,可以写很多的方法。18 this._commandWindow.setHandler('test', this.test.bind(this));19 this.addWindow(this._commandWindow);20};21
22//这个是test方法的具体功能,也就是点击之后触发的事件23Scene_Title.prototype.test = function(){24 console.log("点击了按钮!!!")25}
xxxxxxxxxx1441(() => {2
3 //1.自己的自定义窗体4 function Window_Test() {5 this.initialize.apply(this, arguments);6 }7
8 //2.继承一个窗体类,根据不同需求可以自行改动9 Window_Test.prototype = Object.create(Window_Command.prototype);10
11 //3.把构造函数指向自己12 Window_Test.prototype.constructor = Window_Test;13
14 //4.写初始化函数15 Window_Test.prototype.initialize = function (x, y) {16 Window_Command.prototype.initialize.call(this, x, y)//xy代表位置17 this.refresh();//刷新窗口18 this.activate();//激活19 }20
21 //窗口类的核心方法,自定义代码就在这里写22 Window_Test.prototype.makeCommandList = function () {23 this.addCommand("自定义的指令", '指令名', true);//指令名是代码内部调用的,可以通过setHandler来使用24 //自定义代码,都在这里写。25 }26
27
28 //右侧的说明区域29 function 自定义HELP(){30 this.initialize.apply(this, arguments);31 }32 自定义HELP.prototype = Object.create(Window_Base.prototype);33 自定义HELP.prototype.constructor = 自定义HELP;34
35 自定义HELP.prototype.initialize = function () {36 var x = 250;37 var y = 0;38 var width = 500;39 var height = this.fittingHeight(2);//行宽40 Window_Base.prototype.initialize.call(this, x, y, width, height);41 this._text = '';42 }43
44 //窗口类的核心方法,自定义代码就在这里写45 自定义HELP.prototype.setInfo = function(text){46 this.contents.clear();47 this._text =text;48 this.drawTextEx(this._text, this.textPadding(), 0);49 }50
51
52
53 //这个就是点击指令后的场景54 function Scene_Test() {55 this.initialize.apply(this, arguments)56 }57
58 Scene_Test.prototype = Object.create(Scene_MenuBase.prototype);//自行查看窗体所在的场景59 Scene_Test.prototype.constructor = Scene_Test;60 Scene_Test.prototype.initialize = function () {61 Scene_MenuBase.prototype.initialize.call(this)62 }63
64 Scene_Test.prototype.create = function () {65 Scene_MenuBase.prototype.create.call(this)66 this.createTestWindow();67 this.createHelpWindow();68 this.bindCommands();69 }70
71 Scene_Test.prototype.start = function () {72 Scene_MenuBase.prototype.start.call(this)73 this.windowTest.refresh();74 }75
76 Scene_Test.prototype.createHelpWindow =function(){77 this._helpWindow = new 自定义HELP();78 this._helpWindow.setInfo("hello world");79 this.addWindow(this._helpWindow);80 } 81
82 Scene_Test.prototype.createTestWindow = function () {83
84 var x = 0;85 var y = 0;86 // console.log(xx,yy)87 this.windowTest = new Window_Test(x, y)88 this.addWindow(this.windowTest);//根据需求,可以添加很多个窗口89
90 }91
92 Scene_Test.prototype.bindCommands = function () {93 this.windowTest.setHandler('ok', this.windowOK.bind(this));94 this.windowTest.setHandler('cancel', this.windowCancel.bind(this));95 }96
97 //当点击时触发98 Scene_Test.prototype.windowOK = function () {99 console.log("ok")100 this.windowTest.activate();101
102 // 监听按键,改变说明区域的文字103 this._helpWindow.setInfo("我是自定义的指令哟");104
105 }106
107 //当返回时除法108 Scene_Test.prototype.windowCancel = function () {109 console.log("cancel")110 SceneManager.pop();//返回上一级111 }112 113
114
115
116 Window_MenuCommand.prototype.addOriginalCommands = function () {//这个方法是专门给我们提供的,可以用来重写。117 //在菜单指令中添加指令,但是要注意,如果只写了这个,是没有效果的,118 //必须在createCommandWindow中,给test注册响应函数才能点进去119 this.addCommand('指令名', 'test', true);120 }121
122 123 Scene_Menu.prototype.commandTest = function () {124 SceneManager.push(Scene_Test);125 }126
127
128 Scene_Menu.prototype.createCommandWindow = function () {129
130 this._commandWindow = new Window_MenuCommand(0, 0);131 this._commandWindow.setHandler('item', this.commandItem.bind(this));132 this._commandWindow.setHandler('skill', this.commandPersonal.bind(this));133 this._commandWindow.setHandler('equip', this.commandPersonal.bind(this));134 this._commandWindow.setHandler('status', this.commandPersonal.bind(this));135 this._commandWindow.setHandler('formation', this.commandFormation.bind(this));136 this._commandWindow.setHandler('options', this.commandOptions.bind(this));137 this._commandWindow.setHandler('save', this.commandSave.bind(this));138 this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));139 this._commandWindow.setHandler('cancel', this.popScene.bind(this));140 this._commandWindow.setHandler('test', this.commandTest.bind(this));141 this.addWindow(this._commandWindow);142 }143
144})()
xxxxxxxxxx381(function () {2
3 //1.创建一个函数,名字就是你自定义窗体的名字4
5 function 窗体名() {6 this.initialize.apply(this, arguments);7 }8 //2.继承Window_Base类9 窗体名.prototype = Object.create(Window_Base.prototype);10 窗体名.prototype.constructor = 窗体名;11
12 //3.初始化窗体大小13 var statusWindow = {14 x: 240,15 y: 0,16 width: 576,17 height: 62418 };19 窗体名.prototype.initialize = function () {20 Window_Base.prototype.initialize.call(this, statusWindow.x, statusWindow.y,21 statusWindow.width, statusWindow.height);22 };23
24 //4.写刷新函数,系统会自动调用这个函数25 窗体名.prototype.refresh = function () {26 this.contents.clear();27 this.drawText("hello world", 144, 0, 200);28 };29
30
31
32 //5.将窗口布局到游戏里面33 Scene_Menu.prototype.createStatusWindow = function () {34 this._statusWindow = new 窗体名();35 this.addWindow(this._statusWindow);36 };37
38})();
地图界面
xxxxxxxxxx291(function () {2 //1.创建一个函数,名字就是你自定义窗体的名字3 function 窗体名() {4 this.initialize.apply(this, arguments);5 }6 //2.继承Window_Base类7 窗体名.prototype = Object.create(Window_Base.prototype);8 窗体名.prototype.constructor = 窗体名;9
10 //3.初始化窗体大小11 窗体名.prototype.initialize = function () {12 Window_Base.prototype.initialize.call(this, 0, 0, 100, 100);//分别代表位置和长宽13 this.drawText('莲华', 5, 5, 100, 'left');14 };15
16 //4.写创建窗体函数17 Scene_Base.prototype.创建窗体 = function () {18 this.addWindow(new 窗体名());19 };20
21
22 //5.创建窗体23 var _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;24 Scene_Map.prototype.createDisplayObjects = function () {25 _Scene_Map_createDisplayObjects.call(this);26 this.创建窗体();27 };28
29})();
这个是指左下角那个窗口
xxxxxxxxxx251//构造函数体2function Window_PlayerCount() {3 this.initialize.apply(this, arguments);4}5//继承自Window_Base6Window_PlayerCount.prototype = Object.create(Window_Base.prototype);7//设定构造函数8Window_PlayerCount.prototype.constructor = Window_PlayerCount;9//初始化10Window_PlayerCount.prototype.initialize = function (x, y) {11 var width = 240;12 var height = this.fittingHeight(1);13 Window_Base.prototype.initialize.call(this, x, y, width, height);14 this.drawText('团伙中有' + $gameParty.members().length + '人', 0, 0, 200);15};16//重写Scene_Menu,加入我们自定窗口17Scene_Menu.prototype.create = function () {18 Scene_MenuBase.prototype.create.call(this);19 this.createCommandWindow();20 this.createGoldWindow();21 this.createStatusWindow();22 //加入我们自己的窗口23 var win = new Window_PlayerCount(0, this._commandWindow.height);24 this.addWindow(win);25};
xxxxxxxxxx571//我们对系统提供的精灵类进行复制,创建一个"自定义精灵类"2function 自定义精灵类() {3 this.initialize.apply(this, arguments);4}5自定义精灵类.prototype = Object.create(Sprite.prototype);6自定义精灵类.prototype.constructor = 自定义精灵类;7自定义精灵类.prototype.initialize = function () {8 Sprite.prototype.initialize.call(this);9 //以上为固定写法,不需要弄清楚10 //以下是设置这个精灵类的共同属性,所有这个对象构造的精灵都具有的属性,类比C++中的类11 /*设置框架,即精灵所处矩形范围,精灵的活动区域被限制在此框架内,四个参数分别为左上角的X,Y的坐标,宽度(横),长度(竖)12 需要注意的是X和Y一般是负数,如果大于0图片就会往屏幕外移动*/13 this.setFrame(0, 0, 1000, 1500);14
15 //运行创造子精灵的函数16 this.createAll();17
18 //绘制位图(bitMap)的文字函数19 this.drawText();20
21 //move作用和setFrame是一样的,两个数值相当于把框架沿x轴y轴移动多少单位22 this.move(20, 10);23};24
25自定义精灵类.prototype.createAll = function () {26 //使用图片来建立精灵27 this._clock = new Sprite(ImageManager.loadBitmap('img/pictures/', "SF_Actor3_8", true));28 //使用系统提供的位图对象建立精灵,这里使用的是一个空位图,具体的文字会用drawText函数上描绘29 this._cont = new Sprite(new Bitmap(380, 418)); //定义位图的宽和高 30 //anchor,范围0-1,设置精设置绘制精灵的起始坐标,0.5可以令其居中显示31 this._clock.anchor.x = this._clock.anchor.y = 0.5; 32 /*这里的setFrame是精灵中的精灵活动范围,低级精灵不能超过其容器活动范围,不然无法显示33 _clock精灵属于mySprite类,其活动范围不能超过他的类,如果不setFrame,系统将会给一个默认值*/34 this._clock.setFrame(0, 0, 100, 100);35 this._clock.move(32, 42); 36 this.addChild(this._clock);37 this.addChild(this._cont);38};39
40//这里定义了一个函数,是用于对前面构建_cont精灵所用位图进行描绘的41自定义精灵类.prototype.drawText = function () {42 this._cont.bitmap.fontSize = 30; //设置字型大小43 this._cont.bitmap.textColor ="rgb(255,255,255)"||'red'; //设置字体颜色,可用RGB表示法或者英文字符44 //'' +:根据JavaScript语法规则,可以将后面的数据强制转化为字符串,这里$spriteTest.Parameters.text原本就是字符串,这样做法是为了防止出错45 var text = "测试文本 "; //设置文本46 this._cont.bitmap.drawText(text,0, 88, 136, 44);47}48
49
50SUBupdate = Scene_Map.prototype.update;51Scene_Map.prototype.update = function () {52 SUBupdate.call(this);53 this.myMapSprite = new 自定义精灵类();54 //前面已经说过,在构建对象的函数里面已经设置了对象初始值,这里就不需要再设置了55 this.addChild(this.myMapSprite);56 //用addChild函数将精灵加入场景中57};
存放音频素材,下分4个子类
bgm(background music):背景音乐
bgs(background sound):背景音效:
me(music effect):音乐效果
se(sound effect):声音效果
m4a文件:用于手机端,加密后变成rpgmvm文件。
ogg文件:用于PC端,加密后形成rpgmvo文件。
Actor.json——角色数据
Animations.json——动画模块
Armor.json——装备数据
Classes.json——职业数据
CommonEvents.json——公共事件数据
Enemies.json——敌人数据
Items.json——道具数据
MapXXX.json——各地图的详细信息(包括事件
MapInfos.json——各地图的大致信息
Skills.json——技能数据
States.json——状态数据
System.json——系统、类型、用语
Tileset.json——图块组模块
Troop.json——敌群数据
Weapons.json——武器数据
游戏的字体文件
去根目录下fonts文件夹中
打开gamefont.css文件,这个里面就存着字体的信息。
xxxxxxxxxx121@font-face {2 font-family: GameFont;3 /*url里面就是字体文件的路径*/4 src: url("mplus-1m-regular.ttf");5}6
7.IIV::media-controls-play-button,8video::media-controls-start-playback-button {9 opacity: 0;10 pointer-events: none;11 width: 5px;12}把自己下载的ttf文件放入fonts文件夹中,把url里面的名字换成你下载的就行了
顺便一说,fonts文件都放在了C:\Windows\Fonts中,有需要可以自取。
游戏的图标文件
游戏中所有的图片素材
游戏源代码,包括官方的代码和插件代码
游戏中的视频文件
| 素材类型 | 大小 |
|---|---|
| 立绘 | 高度为600px |
| CG | 816*624px |
| 脸图 | 144*144px |
| 一个图块大小 | 48*48px |
| 标题图片 | 816*624px |
PC:16:9
1920*1080
1600*900
animations:动画特效
battlebacks1:战斗背景图,一般都是地面或者战斗近景图
battlebacks2:战斗的远景图,远景图可以省略,近景图必须指定。
characters:角色的行走图,或者其他物品的动作图,大小为48*48
在文件名前面加上半角符号“$”,那么该文件就只能容纳一个角色元。
enemies:敌人的战斗图,也就是战斗时看到的立绘
faces:各种角色的头像,144*144
parallaxes:远景图,尺寸没有限制
pictures:这些图片可以通过事件指令中的显示图片指令显示在游戏中,图片尺寸大小不限。
titles1:标题的背景图
titles2:标题背景图的边框,图片的大小为 816x624 ,Titles1 包含标题画面的背景,titles2 则主要是边框,使用它们可以组成标题画面。
让RPGMV的事件可以自定义触发条件。例如我正在编写一个有时间系统的游戏,我希望这个事件在早晨或者下午触发。改如何实现呢?
可以考虑使用事件的备注来实现。例如可以备注<触发条件:早晨,中午,下午>
编写插件
xxxxxxxxxx701Game_Event.prototype.meetsConditions = function(page) {2 var c = page.conditions;3 if (c.switch1Valid) {4 if (!$gameSwitches.value(c.switch1Id)) {5 return false;6 }7 }8 if (c.switch2Valid) {9 if (!$gameSwitches.value(c.switch2Id)) {10 return false;11 }12 }13 if (c.variableValid) {14 if ($gameVariables.value(c.variableId) < c.variableValue) {15 return false;16 }17 }18 if (c.selfSwitchValid) {19 var key = [this._mapId, this._eventId, c.selfSwitchCh];20 if ($gameSelfSwitches.value(key) !== true) {21 return false;22 }23 }24 if (c.itemValid) {25 var item = $dataItems[c.itemId];26 if (!$gameParty.hasItem(item)) {27 return false;28 }29 }30 if (c.actorValid) {31 var actor = $gameActors.actor(c.actorId);32 if (!$gameParty.members().contains(actor)) {33 return false;34 }35 }36 37 //////////////这里是增加的代码/////////38 var 触发条件 = $dataMap.events[this._eventId].meta.触发条件39 时间 = $gameVariables.value(3);//获得游戏中控制时间的变量40 //这个变量的不同数值代表不同时间段。41 42 if (触发条件) {43 //如果当前游戏时间为1,而且备注中出现了早晨,那么这个事件就会被触发。以此类推。44 if(时间==1 &&触发条件.indexOf("早晨")!== -1 )45 {46 return true;47 }48 if(时间==2 &&触发条件.indexOf("上午")!== -1 )49 {50 return true;51 }52 if(时间==3 &&触发条件.indexOf("中午")!== -1 )53 {54 return true;55 }56 if(时间==4 &&触发条件.indexOf("下午")!== -1 )57 {58 return true;59 }60 if(时间==0 &&触发条件.indexOf("晚上")!== -1 )61 {62 return true;63 }64 65 }66 /////////////////////67 68 return true;69};70
在游戏开发中经常出现需要自己添加一个新按钮或者快捷键的需求。
实现自定义映射其实很简单,我们首先需要知道JS里面如何给一个对象增加属性。其中就有一个对象键值对的赋值。不懂的可以看我的JS基础。
在脚本中,左边写所映射按键的键码,右边写你给这个键起的keyName。
xxxxxxxxxx11Input.keyMapper[65] = "A";这样就把A,这个按键绑定到MV里面了。
具体的键码可以参考附录1。
xxxxxxxxxx41Input.isPressed('A') //按键是否正在被按下2Input.isTriggered() //按键刚刚是否按下3Input.isRepeated() //按键是否连续点击,或者一直处于按下状态4Input.isLongPressed() //按键是否一直按下
但是这就有一个问题,在脚本中如果直接使用if语句,会造成一些问题
xxxxxxxxxx31TouchInput._onMouseDown = function(event) {2 // 什么都不要写3};
xxxxxxxxxx601Window_NameInput.LATIN1 =2 [ '赵','钱','孙','李','王', '马','朱','雷','冯','叔',3 '张','闫','何','庞','郭', '魏','田','和','依','姬',4 '白','丽','展','羽','彭', 'k','l','穆','奴','欧',5 '文','礼','月','日','芳', '鑫','梦','世','叶','晨',6 '华','如','幸','雅','知', '昕','微','杰','悦','翊',7 '荣','美','梅','兰','竹', '菊','珍','镇','|','兴',8 '零','一','二','三','四', '杨','#','$','百','己',9 '五','六','七','八','九', '真','鉴','定','为','建',10 '雷','电','尔','这','边', '可','以','点','换页','确认' ];11Window_NameInput.LATIN2 =12 [ '熊','大','二','砍','树', '光','头','强','狗','猫',13 '克','苏','鲁','小','师', '丛','雨','时','乃','宁',14 '斯','坦','纳','亚','总', '锉','刀','枣','子','姐',15 '洛','必','达','桐','人', '宫','保','鸡','丁','香',16 '深','见','夏','彦','爷', '曼','珠','沙','华','ū',17 '少','中','哥','狡','滑', '莲','花','我','老','婆',18 '奈','亚','拉','托','提', '普','信','男','女','子',19 '帽','子','社','绊','爱', '皮','卡','丘','冒','险',20 '萤','雪','映','月','蛇', '人','乔','的','换页','确认' ];21Window_NameInput.RUSSIA =22 [ 'А','Б','В','Г','Д', 'а','б','в','г','д',23 'Е','Ё','Ж','З','И', 'е','ё','ж','з','и',24 'Й','К','Л','М','Н', 'й','к','л','м','н',25 'О','П','Р','С','Т', 'о','п','р','с','т',26 'У','Ф','Х','Ц','Ч', 'у','ф','х','ц','ч',27 'Ш','Щ','Ъ','Ы','Ь', 'ш','щ','ъ','ы','ь',28 'Э','Ю','Я','^','_', 'э','ю','я','%','&',29 '0','1','2','3','4', '(',')','*','+','-',30 '5','6','7','8','9', ':',';',' ','','OK' ];31Window_NameInput.JAPAN1 =32 [ 'あ','い','う','え','お', 'が','ぎ','ぐ','げ','ご',33 'か','き','く','け','こ', 'ざ','じ','ず','ぜ','ぞ',34 'さ','し','す','せ','そ', 'だ','ぢ','づ','で','ど',35 'た','ち','つ','て','と', 'ば','び','ぶ','べ','ぼ',36 'な','に','ぬ','ね','の', 'ぱ','ぴ','ぷ','ぺ','ぽ',37 'は','ひ','ふ','へ','ほ', 'ぁ','ぃ','ぅ','ぇ','ぉ',38 'ま','み','む','め','も', 'っ','ゃ','ゅ','ょ','ゎ',39 'や','ゆ','よ','わ','ん', 'ー','~','・','=','☆',40 'ら','り','る','れ','ろ', 'ゔ','を',' ','カナ','決定' ];41Window_NameInput.JAPAN2 =42 [ 'ア','イ','ウ','エ','オ', 'ガ','ギ','グ','ゲ','ゴ',43 'カ','キ','ク','ケ','コ', 'ザ','ジ','ズ','ゼ','ゾ',44 'サ','シ','ス','セ','ソ', 'ダ','ヂ','ヅ','デ','ド',45 'タ','チ','ツ','テ','ト', 'バ','ビ','ブ','ベ','ボ',46 'ナ','ニ','ヌ','ネ','ノ', 'パ','ピ','プ','ペ','ポ',47 'ハ','ヒ','フ','ヘ','ホ', 'ァ','ィ','ゥ','ェ','ォ',48 'マ','ミ','ム','メ','モ', 'ッ','ャ','ュ','ョ','ヮ',49 'ヤ','ユ','ヨ','ワ','ン', 'ー','~','・','=','☆',50 'ラ','リ','ル','レ','ロ', 'ヴ','ヲ',' ','英数','決定' ];51Window_NameInput.JAPAN3 =52 [ 'A','B','C','D','E', 'a','b','c','d','e',53 'F','G','H','I','J', 'f','g','h','i','j',54 'K','L','M','N','O', 'k','l','m','n','o',55 'P','Q','R','S','T', 'p','q','r','s','t',56 'U','V','W','X','Y', 'u','v','w','x','y',57 'Z','[',']','^','_', 'z','{','}','|','~',58 '0','1','2','3','4', '!','#','$','%','&',59 '5','6','7','8','9', '(',')','*','+','-',60 '/','=','@','<','>', ':',';',' ','かな','決定' ];xxxxxxxxxx11$gameParty.leader()._name = prompt("请输入姓名!")
直接修改数字。
xxxxxxxxxx31DataManager.maxSavefiles = function() {2 return 你想要的数字;3};
RPGMV如果想要存档,在以往只能通过 场景控制中的打开存档界面进行保存。这就会产生一个很难解决的需求问题。
如何在RPGMV播放剧情的时候存档?比如在制作GalGame的时候,如何做到随时存档?
而且在自动保存的时候,也需要保存很多自定义的变量。如何操作呢?
xxxxxxxxxx761/*:2 * @plugindesc3 * 管理和处理游戏剧情用4 * 5 * @help6 * 本插件提供了全局存档的控制接口,以及如何保存读取自定义的数据。如果没有自定义数据,不要修改$gloablData的内容即可7 * 如果想要控制全局存档需要两个步骤8 * 1. 在$storyGlobalInfo中添加变量9 * 2. 在使用后要记得保存,例如:10 * $gloablData.某个自定义数据 = true;11 * StoryControl.autoSave();12 * window.close()13 */14
15class StoryControl {16 //自动保存17 static autoSave(savePosition = 1) {//默认第一个存档,可以改18 console.log("保存成功")19 $gameSystem.onBeforeSave();20 DataManager.saveGame(savePosition)21 }22 //自动加载23 static autoLoad(savePosition = 1) {24
25 DataManager.loadGame(savePosition)26 }27
28 //加载存档的全局数据29 static loadStoryInfo() {30
31 //游戏每次加载的时候,首先加载存档,如果没有存档,那么就先保存再加载。32
33 var tempGlobalInfo = DataManager.loadGlobalInfo() || [];34 try {35 //tempGlobalInfo[0]是个null,真正的数据在136 $gloablData = tempGlobalInfo[1].自定义数据;37 } catch (error) {38 //要是第一次游戏,那么递归一下,再次加载存档39 this.autoSave();40 //把读取的数据存到$gloablData,以便使用41 $gloablData = this.loadStoryInfo();42 }43 return $gloablData;44 }45
46 //保存全局数据47 static saveGlobalInfo(){48 var tempGlobalInfo = DataManager.loadGlobalInfo();49 tempGlobalInfo[1].自定义数据=$gloablData;50 DataManager.saveGlobalInfo(tempGlobalInfo)51 }52}53
54
55//自定义数据,这个是初始值,之后会被覆盖56$gloablData = {57 某数据: 0,58};59
60
61//重写全局存档的内容62DataManager.makeSavefileInfo = function () {63 var info = {};64 info.globalId = this._globalId;65 info.title = $dataSystem.gameTitle;66 info.characters = $gameParty.charactersForSavefile();67 info.faces = $gameParty.facesForSavefile();68 info.playtime = $gameSystem.playtimeText();69 info.timestamp = Date.now();70
71 //如果希望保存自定义的内容,只需要给info添加属性即可。72 //但是为了更好地获得数据,可以用一个新变量$gloablData来保存这个值。73 info.自定义数据 = $gloablData;//自定义的数据74 return info;75};76
在一些创意性游戏中,弹幕可以增加氛围和趣味性。
xxxxxxxxxx761/*:2* @plugindesc 弹幕系统3* @author 闫辰祥4* @help 可以发送弹幕5* 使用时可以使用默认值,比如 new Danmaku(['测试','文字'])6* 也可以详细进行配置,比如 new Danmaku(['测试','文字'],{color:"red"}),7* 也可以同时对多个弹幕进行配置,比如 new Danmaku(['测试','文字',"123"],{color:"red"},{fontSize:"100px"})8* new Danmaku(['测试','文字'],{color:"red",fontSize:"100px"})9*/10
11
12
13class DannmakuConfig {14 constructor(config) {15 config = config || {};16 this.time = config.time || 1;//每隔几秒发送一个弹幕17 this.speed = config.speed || 5;//弹幕速度18 this.color = config.color || 'black';//弹幕颜色19 this.fontSize = config.fontSize || '30px';//弹幕大小20 }21}22
23class Danmaku {24 constructor(texts, config) {25 let tempThis = this26 let configs = [new DannmakuConfig()]//27 for (let i = 0; i < config.length; i++) {28 configs[i]= new DannmakuConfig(config[i])29 }30
31 for (let i = 0; i < texts.length; i++) {32 let useconfig = {}33 if(i>=configs.length)34 {35 useconfig = configs[configs.length-1]36 37 }else{38 useconfig = configs[i]39 }40
41 setTimeout(function () {42 43 tempThis.send(texts[i],useconfig)44 }, i*useconfig.time* 1000)45 }46 }47
48 send(text, config) {49 let 弹幕 = document.createElement("div");50 let node = document.createTextNode(text);51 弹幕.appendChild(node);52
53 弹幕.style.position = "fixed";54 弹幕.style.zIndex = "20"55 弹幕.style.whiteSpace = 'nowrap '56 let height = window.innerHeight;57 let width = window.innerWidth;58 弹幕.style.top = Math.random() * height * 0.8 + "px";59 弹幕.style.left = width - 300 + "px"60
61 //可修改变量62 弹幕.style.color = config.color;63 弹幕.style.fontSize = config.fontSize;64 65
66 document.body.appendChild(弹幕);67
68 let timeControler = setInterval(() => {69 弹幕.style.left = parseInt(弹幕.style.left) - config.speed + "px";70 if (parseInt(弹幕.style.left) < -50) {71 clearInterval(timeControler);72 弹幕.parentNode.removeChild(弹幕)73 }74 }, 10);75 }76}
成就系统理论上来说并不是游戏内的一部分,不过随着游戏理论的发展,成就已经成了游戏内不可或缺的一部分。今天我就来给各位科普一下在RPGMV中,成就系统的编写原理。
在css文件夹下创建achievement.css文件
xxxxxxxxxx381.achievment-node{2 background-color: rgba(0, 0, 0, 0.4);3
4 z-index: 10;5 position: absolute;6 left: 50%;7 top: 0%;8 transform: translate(-50%, 0);9 animation: showAchievement 2s;10 color :white;11 12 padding:5%;13}14.title-node{15 font-size : x-large;16}17
18.info-node{19 font-size: large;20}21
22@keyframes showAchievement {23 0% {24 top: -100px;25 }26
27 50% {28 top: 50px;29 }30
31 70% {32 top: 50px;33 }34
35 100% {36 top: 0px;37 }38}
xxxxxxxxxx631/*:2 * @plugindesc 成就系统3 * @author 闫辰祥4 * @help 直接使用 例如 $gameAchievement.add("梦之始","开始游戏")5 */6
7
8(function () {9 var stylesheet = document.createElement("link")10 stylesheet.rel = "stylesheet"11 stylesheet.href = "./css/achievement.css"12 stylesheet.type = "text/css"13 document.head.appendChild(stylesheet)14})()15
16
17
18
19//游戏成就系统20var $gameAchievement = {}21$gameAchievement._achievements = [];22
23$gameAchievement.add = function (title, info) {24
25 //如果已经获得了这个成就,那么就不添加这个了26 for (let i = 0; i < $gameAchievement._achievements.length; i++) {27 if ($gameAchievement._achievements[i].title == title)28 return false;29
30 }31 //添加成就信息32 var achievmentRecord = { title, info }33 $gameAchievement._achievements.push(achievmentRecord);34
35
36 var achievmentNode = document.createElement("div");37 achievmentNode.classList += "achievment-node"38
39 var titleNode = document.createElement("div");40 titleNode.appendChild(document.createTextNode("获得成就:" + title))41 titleNode.classList += "title-node"42
43
44 var infoNode = document.createElement("div");45 infoNode.appendChild(document.createTextNode(info))46 infoNode.classList += "info-node"47
48 achievmentNode.appendChild(titleNode);49 achievmentNode.appendChild(infoNode);50 document.body.appendChild(achievmentNode);51
52
53
54 setTimeout(() => {55
56 achievmentNode.parentNode.removeChild(achievmentNode);57
58 }, 10000)59
60 return true;61}62
63
xxxxxxxxxx741/*:2* @plugindesc 本插件用于给一个事件添加可以鼠标左键点击的效果3* 4* @author 闫辰祥5* 6*7* 8* 9* @help 10* 插件指令:11* 事件点击 开始12* 事件点击 关闭13* 14* 安装好之后,用鼠标点击事件,然后事件就会被触发15* 对不希望触发的事件,可以在备注加上 <不可点击> 来关闭触发16*17*18* 技术群:52924531119*/20
21
22var 闫 = 闫 || {};23
24闫.Parameters = PluginManager.parameters('闫_鼠标触发事件');25
26
27var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;28Game_Interpreter.prototype.pluginCommand = function (command, args) {29 _Game_Interpreter_pluginCommand.call(this, command, args);30
31 if (command === '事件点击') {32 switch (args[0]) {33 case '开始':34 可以开始点了 = true35 break;36 case '关闭':37 可以开始点了 = false38 break;39 }40 }41};42
43var 可以开始点了 = true44var temp_TouchInput_onMouseDown = TouchInput._onMouseDown45
46TouchInput._onMouseDown = function (event) {47 temp_TouchInput_onMouseDown.call(this, event)48
49 if($dataMap == null)50 {51 return52 }53 if (event.button === 0 && 可以开始点了) {54 var x = Graphics.pageToCanvasX(event.pageX);55 var y = Graphics.pageToCanvasY(event.pageY);56
57 x = $gameMap.canvasToMapX(TouchInput.x);58 y = $gameMap.canvasToMapY(TouchInput.y);59
60 var event = $gameMap.eventsXy(x, y)[0];61
62 63 var eventId = $gameMap.eventIdXy(x,y);64 if (!event)65 return66 if(!event.page())67 return68 if ($dataMap.events[eventId].meta.不可点击)69 return70
71 event.start();72 }73};74
xxxxxxxxxx1641/*:2 * @plugindesc 可以对某一个事件来使用道具3 * @author 闫辰祥4 * @help 首先对需要使用的事件写上注释,格式为 <name:xxx>5 * case里面的是使用道具的名称 meta.name就是对应的事件名称6 */7
8function itemUse(itemName) {9
10 var eventID = getEventID();11 if (!eventID) {12 $gameMessage.add("似乎没有什么用");13 $gameAchievement.add("虚空对线", "对着空地使用道具")14 return false;15 }16
17 var metaData = $dataMap.events[eventID].meta18 switch (itemName) {19 case "钥匙":20 if (metaData.name == "门") {21 if (metaData.switch) {22 $gameSwitches.setValue(metaData.switch, true);23 }24 if (metaData.info) {25 $gameMessage.add(metaData.info);26 }27 return true;28 }29
30 break;31 case "除草镰":32 if (metaData.name == "草") {33 $gameSelfSwitches.setValue([metaData.mapID, eventID, 'A'], true)34 let value = $gameVariables.value(1) + 135 $gameVariables.setValue(1, value);36 $gameMessage.add("目前一共除草了" + $gameVariables.value(1) + "个")37
38 if ($gameVariables.value(1) == 15)39 $gameAchievement.add("除草狂魔", "除了15个艹")40 if ($gameVariables.value(1) == 25)41 $gameAchievement.add("手不累吗?", "除了所有的草")42 return true;43 }44 else if (metaData.name == "草字头") {45 if (metaData.word == "荚") {46 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)47 return true;48 }49 }50 else if (metaData.name == "方妍") {51 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)52 return true;53 }54 else if (metaData.name == "草席") {55 $gameMessage.add("(还是不要动人家东西吧,)")56 return true;57 }58 else if (metaData.name == "芳") {59 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)60 return true;61 } 62 else if (metaData.name == "小兰") {63 $gameMessage.add(",,,,,,")64 $gameMessage.add("你在干什么?")65 $gameMessage.add("(糟糕,她好像生气了)")66 $gameAchievement.add("见人就砍", "试图用除草镰去砍小兰")67 return true;68 }69
70 else if(metaData.name == "花"){71 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)72 $gameAchievement.add("辣手摧花","除掉了花")73 return true;74 }75
76 else if(metaData.name == "莲华"){77 console.log(metaData.name)78 if($gameTroop._inBattle){79 $gameSwitches.setValue(30, true);80 }81 return true;82 }83 84 break;85 case "苗":86 if (metaData.name == "犬") {87 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)88 $gameAchievement.add("我虽然不是人,但你是真的狗", "把犬变成猫")89 return true;90 }91 break;92 case "伐木斧":93 if (metaData.name == "栅") {94 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)95 $gameMessage.add("砍掉了栅的木,掉落了册")96 return true;97 }98 99 else if (metaData.name == "栏") {100 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)101 $gameMessage.add("砍掉了栅的木,掉落了兰")102 return true;103 }104 else if (metaData.name == "樯") {105 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)106 $gameMessage.add("木墙被轻易地砍坏了")107 return true;108 }109 else if (metaData.name == "树") {110 $gameMessage.add("乱砍别人家树,人家会生气的。")111 $gameAchievement.add("光头强", "不分青红皂白砍别人的树")112 return true;113 }114 else if(metaData.name == "渠"){115 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)116 return true;117 }118 else if(metaData.name == "桌子"){119 $gameMessage.add("(如果把人家桌子砍坏了,估计会被打死吧——__——)")120 return true;121 }122 else if(metaData.name == "椅子"){123 $gameMessage.add("(为什么最近总想着去砍东西呢)")124 return true;125 }126 else if(metaData.name == "木门"){127 $gameMessage.add("门被劈开了")128 $gameSelfSwitches.setValue([$gameMap._mapId, eventID, 'A'], true)129 return true;130 }131 break;132
133 default:134 return false;135 }136 $gameAchievement.add("判断失败", "道具没有生效")137 $gameMessage.add("似乎没有什么用");138 return false;139}140
141function getEventID() {142 var vector = [0, 0];143 switch ($gamePlayer.direction()) {144 case 2:145 vector = [0, 1]146 break147 case 4:148 vector = [-1, 0]149 break150 case 6:151 vector = [1, 0]152 break153 case 8:154 vector = [0, -1]155 break156 default:157 }158 var eventPosition = {}159 eventPosition.x = $gamePlayer.x + vector[0]160 eventPosition.y = $gamePlayer.y + vector[1]161 return $gameMap.eventIdXy(eventPosition.x, eventPosition.y)162}163
164
xxxxxxxxxx1301/*:2 * @plugindesc 用于文件的读写3 * 4 * @author 闫辰祥5 *6 * @param 文件7 * @desc 文件名8 * @default test9 *10 * @param 文件夹11 * @desc 保存文件的文件夹名12 * @default ./13 * 14 * 15 * @param 扩展名16 * @desc 文件扩展名,默认txt17 * @default txt18 * 19 * 20 * @param 内容21 * @desc 需要写入的内容22 * @default hello world23 * 24 * 25 * @help26 * MV是不支持fs模块的,但是还是需要文件读写怎么办呢?27 * 这时候就可以用这个插件了。28 * 29 * 30 * 其中文件夹的路径是从游戏项目根目录开始的31 * 你不需要写引号,MV会自己给你加上32 * 比如你想访问 "./data/test.txt"33 * 那么你的参数应该这样写34 * 35 * - 文件:test36 * - 文件夹 ./data/37 * - 扩展名 txt38 * 39 * 然后游戏的data文件夹下就会出现test.txt40 * 41 * 插件指令:42 * FileAccess write //写入文件43 * FileAccess isEqualTo "某某某字符串" //是否和文件的内容一致44 * 45 * !!!!!!!注意!!!!!!!!!!!46 * 本代码是基于node环境的,47 * 也就是说如果用网页打开的话,48 * 本代码将会报错49 * 50 * 很容易理解,因为浏览器要是可以随随便便读写文件的话,51 * 那么你的网络环境也太危险了。52 * 53 * 所以说,调试这个插件的时候,请直接在工程里面打开游戏,54 * 不要点index.html打开游戏。55 * 56 * 57 *58 */59//作者:闫辰祥60var Yan = Yan || {};61Yan.Parameters = PluginManager.parameters('Yan_FileAccess');62Yan.Parameters.folder = String(Yan.Parameters['文件夹'] || './');63Yan.Parameters.file = String(Yan.Parameters['文件'] || 'test');64Yan.Parameters.extension = String(Yan.Parameters['扩展名'] || 'txt');65Yan.Parameters.content = String(Yan.Parameters['内容'] || 'hello world');66
67
68var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;69
70Game_Interpreter.prototype.pluginCommand = function (command, args) {71 _Game_Interpreter_pluginCommand.call(this, command, args);72 if (command === 'FileAccess') {73 switch (args[0]) {74 case 'write':75 write();76 break;77 case 'isEqualTo':78 isEqualTo(args[1]);79 break;80 }81 }82};83
84
85function isEqualTo(string){86 const fs = require('fs');87
88 let folder = Yan.Parameters.folder;89 let file = Yan.Parameters.file;90 let extension = Yan.Parameters.extension;91 let path = folder + file + "." + extension;92
93 fs.readFile(path,'utf-8', function (err, data) {94 if (err) 95 alert("读取失败!");96
97 alert(data.toString()=="true");98 });99}100
101function write() {102 const fs = require('fs');103
104 let folder = Yan.Parameters.folder;105 let file = Yan.Parameters.file;106 let extension = Yan.Parameters.extension;107 let content = Yan.Parameters.content;108
109 content = `<!DOCTYPE html>110 <html lang="ch">111 <head>112 <meta charset="UTF-8">113 <meta http-equiv="X-UA-Compatible" content="IE=edge">114 <meta name="viewport" content="width=device-width, initial-scale=1.0">115 <title>Document</title>116 </head>117 <body>118 hello world119 </body>120 </html>121 `122
123 let path = folder + file + "." + extension;124 //writeFile会覆盖原有的内容,而且若找不到文件,会自己创建一个文件125 fs.writeFile(path, content, (err) => {126 if (err)127 alert("写入失败!");128 });129}130
xxxxxxxxxx1621/*:2 * @plugindesc 本游戏专用的数据脚本3 * @author 闫辰祥4 */5
6function Data(year, month, day) {7 this.year = year;8 this.month = month;9 this.day = day;10}11
12function Game_Infor_Manager(chapter, title, date) {13 this.chapter = chapter; //章节数14 this.title = title; //标题15 this.date = date; //日期16 //this.gamePlayedNums = 1;//周目数17}18
19
20//注意这里明显没写完,因为我懒得写21//而且我估计应该没有人能打完这么多天22Game_Infor_Manager.prototype.datePlus = function () {23 this.date.day++;24 if (this.date.day == 31) {25 this.month++;26 this.date.day = 1;27 }28
29}30
31Game_Infor_Manager.prototype.dateMinus = function () {32 this.date.day--;33 if (this.date.day == 0) {34 this.month++;35 this.date.day = 31;36 }37
38}39
40Game_Infor_Manager.prototype.dateChange = function (year, month, day) {41 this.date.day = day;42 this.date.month = month;43 this.date.year = year;44}45
46
47
48
49
50// 时间循环51Game_Infor_Manager.prototype.time = 0;52Game_Infor_Manager.prototype.bgmPlay = true;53Game_Infor_Manager.prototype.timeToSleep = true;54
55Game_Infor_Manager.prototype.timeControler = function () {56
57
58
59 if (this.bgmPlay == false) return;60
61
62
63 var bgm = new Object();64 bgm.volume = 100;//响度65 bgm.pitch = 100;//音调 66 bgm.pan = 0;//偏移67
68
69 //$gameVariables._data[4]代表一天的时间70 //0代表清晨,1代表正午,2代表下午,3黄昏,4代表夜晚,5代表深夜。71
72 if ($gameVariables._data[6])73 this.time = $gameVariables._data[6];74 this.time += 0.4;75 $gameVariables._data[6] = this.time;76
77
78
79 if (this.time < 1000) {80 $gameScreen.startTint([0, 0, 0, 0], 1); //清晨81 bgm.name = "晨曦";//bgm的名称82 AudioManager.playBgm(bgm);83 $gameVariables._data[4] = 0;84 this.timeToSleep = true;85 }86
87 if (this.time >= 1000 && this.time < 2500) {88 $gameScreen.startTint([60, 60, 60, 0], 800); //正午89 AudioManager.fadeOutBgm(40);90 $gameVariables._data[4] = 1;91
92 }93
94
95
96 if (this.time >= 2500 && this.time < 3500) {97 $gameScreen.startTint([0, 0, 0, 0], 600); //下午98 bgm.name = "黄昏";//bgm的名称99 AudioManager.playBgm(bgm);100 $gameVariables._data[4] = 2;101 }102
103 if (this.time >= 3500 && this.time < 4500) {104 $gameScreen.startTint([68, -34, -34, 0], 1000); //黄昏105 $gameVariables._data[4] = 3;106 AudioManager.fadeOutBgm(30);107 }108
109
110 if (this.time >= 4500) {111 $gameScreen.startTint([-68, -68, 0, 68], 1000); //夜晚112 bgm.name = "深夜";//bgm的名称113 AudioManager.playBgm(bgm);114 $gameVariables._data[4] = 4;115 }116
117
118
119
120 if (this.time >= 6000) {121 $gameScreen.startTint([-120, -100, 0, 68], 200); //深夜122
123 if (this.timeToSleep) {124 if ($gameMap._mapId == 6) {125 //如果已经在房子里面的话,不进行跳转126 } else {127 $gameMessage.add("太晚了,回去睡觉吧。");128 $gamePlayer.reserveTransfer(6, 8, 14, 0, 0);129
130 }131 this.timeToSleep = false;132
133 }134 $gameVariables._data[4] = 5;135 }136
137}138
139
140Game_Infor_Manager.prototype.setTime = function (num) {141 this.time = num;142 $gameVariables._data[6]=num;143}144
145Game_Infor_Manager.prototype.bgmClose = function () {146 this.bgmPlay = false;147}148
149Game_Infor_Manager.prototype.bgmOpen = function () {150 this.bgmPlay = true;151}152
153Game_Infor_Manager.prototype.clearItems = function () {154 for (let i = 0; i < 21; i++)155 $gameParty._items[i] = 0;156}157
158
159
160
161var $gameInfor = new Game_Infor_Manager(1, "美好的美一天", new Data(2021, 3, 15));162
可以在标题页更换标题图
xxxxxxxxxx351let leftBtn= document.createElement("div");2leftBtn.id = "leftBtn"3leftBtn.innerText ="左翻页"4leftBtn.style.fontSize = "30px"5leftBtn.style.color = "pink"6leftBtn.style.position = "fixed" 7leftBtn.style.top = "500px"8leftBtn.style.left = "0px"9leftBtn.style.zIndex = 9999;10document.body.appendChild(leftBtn);11
12
13
14leftBtn.onclick = function(){15 $dataSystem.title1Name="CrossedSwords"16 SceneManager.goto(Scene_Title);17}18
19
20
21let rightBtn= document.createElement("div");22rightBtn.id = "rightBtn"23rightBtn.innerText ="右翻页"24rightBtn.style.fontSize = "30px"25rightBtn.style.color = "pink"26rightBtn.style.position = "fixed" 27rightBtn.style.top = "500px"28rightBtn.style.right = "0px"29rightBtn.style.zIndex = 9999;30document.body.appendChild(rightBtn);31
32rightBtn.onclick = function(){33 $dataSystem.title1Name="Castle"34 SceneManager.goto(Scene_Title);35}
xxxxxxxxxx5501
2var Yan_util = Yan_util || {}3
4Yan_util.getTouchEvent = function () {5 var vector = [0, 0];6 switch ($gamePlayer.direction()) {7 case 2:8 vector = [0, 1]9 break10 case 4:11 vector = [-1, 0]12 break13 case 6:14 vector = [1, 0]15 break16 case 8:17 vector = [0, -1]18 break19 default:20 }21 var eventPosition = {}22 eventPosition.x = $gamePlayer.x + vector[0]23 eventPosition.y = $gamePlayer.y + vector[1]24 return $gameMap.eventsXy(eventPosition.x, eventPosition.y)[0]25}26
27
28
29
30
31Yan_util.addMethod = function (object, name, fn) {32 var old = object[name]; object[name] = function () {33 if (fn.length == arguments.length)34 return fn.apply(this, arguments)35 else if (typeof old == 'function')36 return old.apply(this, arguments);37 };38}39
40Yan_util.random = function (m, n) {41 return Math.ceil(Math.random() * (n - m + 1) + m - 1);42}43
44
45
46
47
48
49/**50 * 即时战斗系统,共分为以下几个部分:51 * 全局初始化52*/53
54
55
56var RealtimeBattleSystem = RealtimeBattleSystem || {}57
58
59
60// 初始化61RealtimeBattleSystem.init = function () {62
63
64 nw.Window.get().maximize()//最大化65
66
67 this.attack = true;68
69 this._callbackQueue = [];//回调函数队列,用于事件触发70 RealtimeBattleSystem.enemyInit()//更新敌人71
72 RealtimeBattleSystem.bindUpdate()73
74 RealtimeBattleSystem.UIInit()75}76
77
78
79
80RealtimeBattleSystem.getWeapon = function () {81 let weapon = $dataWeapons[$gameParty.leader()._equips[0]._itemId]82 return weapon ? weapon.name : '空手'83}84
85
86RealtimeBattleSystem.getHat = function () {87 let armor = $dataArmors[$gameParty.leader()._equips[2]._itemId]88 return armor ? armor.name : '没穿'89}90
91
92
93RealtimeBattleSystem.getArmor = function () {94 let armor = $dataArmors[$gameParty.leader()._equips[3]._itemId]95 return armor ? armor.name : '空手'96}97
98
99RealtimeBattleSystem.creatUI = function () {100
101 // 左侧的状态栏102 var stateBar = document.createElement('div')103 stateBar.classList += "state-bar"104
105 var hpBar = document.createElement('div')106 hpBar.id = "hp-bar"107
108
109 var mpBar = document.createElement('div')110 mpBar.id = "mp-bar"111
112
113 var defBar = document.createElement('div')114 defBar.id = "def-bar"115
116
117 var atkBar = document.createElement('div')118 atkBar.id = "atk-bar"119
120
121
122
123 stateBar.appendChild(hpBar);124 stateBar.appendChild(mpBar);125 stateBar.appendChild(defBar);126 stateBar.appendChild(atkBar);127 document.body.appendChild(stateBar)128
129
130
131 //右侧的装备栏132 var equipBar = document.createElement('div')133 equipBar.classList += "equip-bar"134
135
136 var weaponBar = document.createElement('div')137 weaponBar.innerHTML = `手持:${RealtimeBattleSystem.getWeapon()} `138
139
140 var headBar = document.createElement('div')141 headBar.innerHTML = `头戴:${RealtimeBattleSystem.getHat()} `142
143
144 var clothesBar = document.createElement('div')145 clothesBar.innerHTML = `身披:${RealtimeBattleSystem.getArmor()} `146
147 equipBar.appendChild(weaponBar);148 equipBar.appendChild(headBar);149 equipBar.appendChild(clothesBar);150 document.body.appendChild(equipBar)151}152
153
154RealtimeBattleSystem.updateUI = function () {155
156 var hpBar = document.querySelector("#hp-bar")157 hpBar.innerHTML = `生命值:${$gameParty.leader()._hp} 之于 ${$gameParty.leader().mhp}`158
159 var mpBar = document.querySelector("#mp-bar")160 mpBar.innerHTML = `法术值:${$gameParty.leader()._mp} 之于 ${$gameParty.leader().mmp}`161
162 var defBar = document.querySelector("#def-bar")163 defBar.innerHTML = `防御力:${$gameParty.leader().def}`164
165
166 var atkBar = document.querySelector("#atk-bar")167 atkBar.innerHTML = `攻击力:${$gameParty.leader().atk}`168}169
170
171
172RealtimeBattleSystem.普通攻击 = function () {173 //普通攻击174 if (Input.isTriggered('ok')) {175
176 var targetEvent = Yan_util.getTouchEvent()177 if (targetEvent == void 0)178 return179 targetEvent.hp -= $gameParty.leader().atk180 targetEvent.requestAnimation(2)181
182 } //按键是否正在被按下183}184
185
186RealtimeBattleSystem.远程攻击 = function () {187
188}189
190RealtimeBattleSystem.蓄力攻击 = function () {191
192 //蓄力攻击193 if (Input.isLongPressed('ok')) {194 if (this._attack && $gameParty.leader()._mp >= 10) {195 this._attack = false;196 $gamePlayer.requestAnimation(1);197 $gameParty.leader().gainMp(-10)198 }199 }200 if (Input.isPressed('ok') === false) {201 this._attack = true;202 }203}204
205
206
207RealtimeBattleSystem.checkAttack = function () {208 this.普通攻击()209 this.蓄力攻击()210}211
212
213
214//判断玩家相对于事件到底在哪个方向215RealtimeBattleSystem.eventPositionToPlayer = function (gameEvent) {216 if ($gamePlayer._realX > gameEvent._realX && $gamePlayer._realY > gameEvent._realY) {217 return "右下"218 }219 else if ($gamePlayer._realX > gameEvent._realX && $gamePlayer._realY < gameEvent._realY) {220 return "右上"221 } else if ($gamePlayer._realX < gameEvent._realX && $gamePlayer._realY > gameEvent._realY) {222 return "左下"223 } else if ($gamePlayer._realX < gameEvent._realX && $gamePlayer._realY < gameEvent._realY) {224 return "左上"225 }226}227
228
229RealtimeBattleSystem.loadCSS = function () {230 var stylesheet = document.createElement("link")231 stylesheet.rel = "stylesheet"232 stylesheet.href = "./css/realtimeBattleSystem.css"233 stylesheet.type = "text/css"234 document.head.appendChild(stylesheet)235}236
237RealtimeBattleSystem.UIInit = function () {238 RealtimeBattleSystem.loadCSS()//加载UI样式239 RealtimeBattleSystem.creatUI()//创建UI240}241
242RealtimeBattleSystem.cheackEnemyAttack = function (enemyEvent) {243
244 var vector = [0, 0];245 switch (enemyEvent._direction) {246 case 2:247 vector = [0, 1]248 break249 case 4:250 vector = [-1, 0]251 break252 case 6:253 vector = [1, 0]254 break255 case 8:256 vector = [0, -1]257 break258 default:259 }260
261 if (enemyEvent._x + vector[0] == $gamePlayer._x && enemyEvent._y + vector[1] == $gamePlayer._y) {262
263 $gameParty.leader().gainHp(-enemyEvent.attack)264 $gamePlayer.requestAnimation(2)265
266 return true;267 }268 return false;269
270
271}272
273
274RealtimeBattleSystem.enemyInit = function () {275 RealtimeBattleSystem._enemys = []276
277
278 for (let i = 1; i < $dataMap.events.length; i++) {279
280
281 let dataEvent = $dataMap.events[i]282 let gameEvent = $gameMap._events[dataEvent.id]283
284
285 if (!dataEvent) {286 break;287 }288 if(!dataEvent.meta.type){289 break290 }291
292
293 RealtimeBattleSystem._enemys.push(gameEvent)294
295
296 if (dataEvent.meta.type == "车") {297 gameEvent.hp = 300;298 gameEvent.attack = 3;299
300 gameEvent.setMoveSpeed(4.3);301 setInterval(function () {302 gameEvent.moveTowardPlayer();//朝向玩家移动303 gameEvent.turnTowardPlayer();304 RealtimeBattleSystem.cheackEnemyAttack(gameEvent)305
306 }, 700)307 }308
309 if (dataEvent.meta.type == "马") {310
311 gameEvent.hp = 350;312 gameEvent.attack = 5;313
314
315
316 setInterval(function () {317 gameEvent.moveTowardPlayer();//先直线走一步318
319 setTimeout(function () {320
321 switch (RealtimeBattleSystem.eventPositionToPlayer(gameEvent)) {322 case "右下":323 gameEvent.moveDiagonally(6, 2); //右下移动324 break;325 case "左下":326 gameEvent.moveDiagonally(4, 2);//移动327 break;328 case "右上":329 gameEvent.moveDiagonally(6, 8);//移动330 break;331 case "左上":332 gameEvent.moveDiagonally(4, 8);//左上移动333 break334 }335 RealtimeBattleSystem.cheackEnemyAttack(gameEvent)336 }, 500)337
338 }, 1000)339 }340
341 if (dataEvent.meta.type == "象") {342
343 gameEvent.hp = 250;344 gameEvent.attack = 10;345
346 setInterval(function () {347
348
349 switch (RealtimeBattleSystem.eventPositionToPlayer(gameEvent)) {350 case "右下":351 gameEvent.moveDiagonally(6, 2); //右下移动352 break;353 case "左下":354 gameEvent.moveDiagonally(4, 2);//移动355 break;356 case "右上":357 gameEvent.moveDiagonally(6, 8);//移动358 break;359 case "左上":360 gameEvent.moveDiagonally(4, 8);//左上移动361 break362 }363
364 setTimeout(function () {365
366 switch (RealtimeBattleSystem.eventPositionToPlayer(gameEvent)) {367 case "右下":368 gameEvent.moveDiagonally(6, 2); //右下移动369 break;370 case "左下":371 gameEvent.moveDiagonally(4, 2);//移动372 break;373 case "右上":374 gameEvent.moveDiagonally(6, 8);//移动375 break;376 case "左上":377 gameEvent.moveDiagonally(4, 8);//左上移动378 break379 }380 RealtimeBattleSystem.cheackEnemyAttack(gameEvent)381 }, 500)382 }, 2000)383 }384
385 if (dataEvent.meta.type == "士") {386
387 gameEvent.hp = 200;388 gameEvent.attack = 30;389 setInterval(function () {390 if ($gamePlayer.x == 4 && $gamePlayer.y == 2)391 gameEvent.moveTowardPlayer();//朝向玩家移动392 RealtimeBattleSystem.cheackEnemyAttack(gameEvent)393 }, 1000)394 }395 if (dataEvent.meta.type == "将") {396 gameEvent.hp = 50;397 gameEvent.attack = 5;398 setInterval(function () {399 RealtimeBattleSystem.cheackEnemyAttack(gameEvent)400 }, 1000)401 }402 if (dataEvent.meta.type == "砲") {403 gameEvent.hp = 200;404 gameEvent.attack = 15;405 setInterval(function () {406 gameEvent.moveTowardPlayer();//朝向玩家移动407 RealtimeBattleSystem.cheackEnemyAttack(gameEvent)408 }, 3000)409 }410
411 if (dataEvent.meta.type == "卒") {412 gameEvent.hp = 300;413 gameEvent.attack = 20;414 setInterval(function () {415 gameEvent.moveTowardPlayer();416 RealtimeBattleSystem.cheackEnemyAttack(gameEvent)417 }, 1000 * Yan_util.random(1, 5))418 }419
420 }421
422}423
424
425
426//增加事件427
428RealtimeBattleSystem.addEventCallback = function (func) {429 this._callbackQueue.push(func);430}431
432
433RealtimeBattleSystem.updateEventCallback = function () {434 if (this._callbackQueue.length == 0)435 return436 (this._callbackQueue.shift())();437
438}439
440
441RealtimeBattleSystem.update = function () {442 RealtimeBattleSystem.checkAttack()443
444 RealtimeBattleSystem.updateEventCallback()445
446 RealtimeBattleSystem.updateUI()447 RealtimeBattleSystem.updateEnemy()448
449}450
451
452RealtimeBattleSystem.checkWin = function () {453 return RealtimeBattleSystem.winFlag454}455
456
457RealtimeBattleSystem.updateEnemy = function () {458
459
460 RealtimeBattleSystem.winFlag = true461 462
463 for (let i = 0; i < RealtimeBattleSystem._enemys.length; i++) {464 if (RealtimeBattleSystem._enemys[i].hp <= 0) {465 $gameMap.eraseEvent(RealtimeBattleSystem._enemys[i]._eventId);466 } else {467
468 RealtimeBattleSystem.winFlag = false469 }470 }471
472 473}474
475
476RealtimeBattleSystem.bindUpdate = function () {477 var tempUpdate = Scene_Map.prototype.update478
479 Scene_Map.prototype.update = function () {480 tempUpdate.call(this)481
482 RealtimeBattleSystem.update()483 }484}485
486
487//动态事件488
489function Dynamic_Event() {490 var newId = $dataMap.events.length491
492 $dataMap.events[newId] = {493 "id": newId,494 "name": "子弹",495 "note": "",496 "pages": [{497 "conditions": {498 "actorId": 1,499 "actorValid": false,500 "itemId": 1,501 "itemValid": false,502 "selfSwitchCh": "A",503 "selfSwitchValid": false,504 "switch1Id": 1,505 "switch1Valid": false,506 "switch2Id": 1,507 "switch2Valid": false,508 "variableId": 1,509 "variableValid": false,510 "variableValue": 0511 },512 "directionFix": true,513 "image": {514 "tileId": 0,515 "characterName": "文字板",516 "direction": 4,517 "pattern": 2,518 "characterIndex": 4519 },520 "list": [{521 "code": 0,522 "indent": 0,523 "parameters": []524 }],525 "moveFrequency": 3,526 "moveRoute": {527 "list": [{ "code": 0, "parameters": [] }],528 "repeat": true,529 "skippable": false,530 "wait": false531 },532 "moveSpeed": 3,533 "moveType": 0,534 "priorityType": 1,535 "stepAnime": false,536 "through": false,537 "trigger": 0,538 "walkAnime": false539 }],540 "x": 6, "y": 6541 }542
543 $gameMap._events[newId] = new Game_Event($gameMap._mapId, newId);544
545 $gamePlayer.reserveTransfer(1, 8, 8, 0, 2)546
547 setInterval(function () {548 $gameMap._events[newId].moveRandom()549 }, 1000)550}
看一个示例
xxxxxxxxxx381 2Window_TitleCommand.prototype.makeCommandList = function() {3
4 this.addCommand(TextManager.newGame, 'newGame');5
6 this.addCommand(TextManager.continue_, 'continue', this.isContinueEnabled());7
8 this.addCommand(TextManager.options, 'options');9
10 this.addCommand("测试", 'test');11
12};13
14
15
16Scene_Title.prototype.createCommandWindow = function() {17
18 this._commandWindow = new Window_TitleCommand();19
20 this._commandWindow.setHandler('newGame', this.commandNewGame.bind(this));21
22 this._commandWindow.setHandler('continue', this.commandContinue.bind(this));23
24 this._commandWindow.setHandler('options', this.commandOptions.bind(this));25
26 this._commandWindow.setHandler('test', this.Test.bind(this));27
28 this.addWindow(this._commandWindow);29
30};31
32 33
34Scene_Title.prototype.Test = function() {35
36 alert("hello world")37
38};
makeCommandList 可以来创建一个函数的显示层。 this.addCommand("测试", 'test'); 前面是显示的内容,后面的绑定的标识符(symbol)
标识符的绑定需要在Scene_Title中完成。this._commandWindow.setHandler('test', this.Test.bind(this));可以来绑定test标识符对应的回调函数
原理是 setHandler函数可以把一个标识符通过数组的索引,绑定到_handlers
xxxxxxxxxx51Window_Selectable.prototype.setHandler = function(symbol, method) {2
3 this._handlers[symbol] = method;4
5};通过callhandler来调用
xxxxxxxxxx91Window_Selectable.prototype.callHandler = function(symbol) {2
3 if (this.isHandled(symbol)) {4
5 this._handlers[symbol]();6
7 }8
9};addCommand方法可以把一个函数的标识符和窗体名绑定到window中
xxxxxxxxxx171Window_Command.prototype.addCommand = function(name, symbol, enabled, ext) {2
3 if (enabled === undefined) {4
5 enabled = true;6
7 }8
9 if (ext === undefined) {10
11 ext = null;12
13 }14
15 this._list.push({ name: name, symbol: symbol, enabled: enabled, ext: ext});16
17};
如果要让RPGMV完全透明,首先我们需要理解以下几个知识点:
RPGMV是一个网页,因此想让他透明本质上是需要网页透明
RPGMV运行在nwjs框架上,因此也需要让nwjs透明
pixijs是控制RPGMV显示的动画库,同样会控制游戏的透明
因此,首先需要让rpgmv的html页面透明
在index.html中,修改背景颜色为透明
xxxxxxxxxx11<body style="background-color:rgba(0, 0, 0, 0);">修改并增加package.json的配置,让html的透明能显示到桌面
xxxxxxxxxx41 "window": {2 "frame": false,3 "transparent": true4 },frame可以取消游戏的框架,取消关闭按钮和最小化最大化按钮。transparent可以让游戏框架透明。
修改pixi.js的源码
ctrl+f,找到下面的代码
xxxxxxxxxx11_this._backgroundColorRgba[3] = _this.transparent ? 0 : 1;可以看到,虽然框架透明了,但是因为pixi也渲染了游戏,导致游戏还是没有透明。这个_backgroundColorRgba,前三个变量控制rgb,第三个控制alpha通道。
所以我们要把这个代码修改为:
xxxxxxxxxx11_this._backgroundColorRgba[3] = 0;
当然,也可以自定义小数,实现半透明
这样配置还是无法实现,透明。因为pixi.js在配置时,默认了禁止透明。所以还要开启透明配置。在RENDER_OPTIONS中,修改transparent为true
xxxxxxxxxx21 RENDER_OPTIONS: {2 transparent: true,如果配置加载还是不透明,可以强制修改透明度。
ctrl+f找到下面的代码
xxxxxxxxxx11_this.transparent = options.transparent修改为
xxxxxxxxxx11_this.transparent = true;此时游戏的标题界面已经透明了,但是游戏画面仍不透明,此时我们要注意,游戏的图块本身就不是透明的,为了测试。我们需要新建一个场景,里面什么都不要加。仅仅测试透明效果。
但是,这时候却发现,屏幕都是黑色。并没有透明。这是很正常的,查看源码发现Spriteset_Base中,this._blackScreen.opacity透明度默认为255。所以我们需要修改。
xxxxxxxxxx11this._blackScreen.opacity = 10;
这个值同样是自定义的。
这时,我们发现,右键菜单,还是无法透明。这是因为Scene_MenuBase中,没有设置透明。查看源码发现Scene_MenuBase.prototype.createBackground时,没有默认透明,因此修改代码为:
xxxxxxxxxx91Scene_MenuBase.prototype.createBackground = function() {2
3 this._backgroundSprite = new Sprite();4 //闫修改,增加了这个5 this._backgroundSprite.opacity = 0;6
7 this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();8 this.addChild(this._backgroundSprite);9};此时,游戏已经全部透明。如果画上图块没有透明,这是因为,图块素材本身也需要透明。
此时只要远景图是透明的,图块是透明的,就可以完全透明化。
注意:nwjs有两个版本NORMAL和SDK。
开发请使用SDK,因为可以debug。
打包使用NORMAL,不支持debug
nw.process.versions.nw
s
将所需的文件压缩为zip文件,注意rar不行!
把zip文件的后缀名改为nw
把这个文件放到nw.js环境同级目录下
在nw.js的目录下打开命令行,输入下面的命令
xxxxxxxxxx11copy /b nw.exe+app.nw app.exe
注意,nw.exe就是咱nw环境的入口,名字可能会变。后面那个就是咱刚才打包的文件。名字也是随意的。
最后那个app.exe就是咱打包之后的文件。
Compression Format设置为disabled
Javascript调用c#
C#调用JavaScript
Assets/Plugins/WebGl,用来放置浏览器要执行的JavaScript代码,插件扩展名为.jslib,将代码文件保存在此路径,当你发布时,这段代码(具体来说)将在build JS中扩展.
代码
xxxxxxxxxx331mergeInto(LibraryManager.library, {2 3 Hello: function () {4 window.alert("Hello, world!");5 },6 7 HelloString: function (str) {8 window.alert(Pointer_stringify(str));9 },10 11 PrintFloatArray: function (array, size) {12 for(var i = 0; i < size; i++)13 console.log(HEAPF32[(array >> 2) + i]);14 },15 16 AddNumbers: function (x, y) {17 return x + y;18 },19 20 StringReturnValueFunction: function () {21 var returnStr = "bla";22 var bufferSize = lengthBytesUTF8(returnStr) + 1;23 var buffer = _malloc(bufferSize);24 stringToUTF8(returnStr, buffer, bufferSize);25 return buffer;26 },27 28 BindWebGLTexture: function (texture) {29 GLctx.bindTexture(GLctx.TEXTURE_2D, GL.textures[texture]);30 },31 32});33
使用C#调用
xxxxxxxxxx381using System.Runtime.InteropServices;2
3[DllImport("__Internal")]4private static extern void Hello();5
6[DllImport("__Internal")]7private static extern void HelloString(string str);8
9[DllImport("__Internal")]10private static extern void PrintFloatArray(float[] array, int size);11
12[DllImport("__Internal")]13private static extern int AddNumbers(int x, int y);14
15[DllImport("__Internal")]16private static extern string StringReturnValueFunction();17
18[DllImport("__Internal")]19private static extern void BindWebGLTexture(int texture);20
21void Start()22{23 Hello();24
25 HelloString("This is a string.");26
27 float[] myArray = new float[10];28 PrintFloatArray(myArray, myArray.Length);29
30 int result = AddNumbers(5, 7);31 Debug.Log(result);32
33 Debug.Log(StringReturnValueFunction());34
35 var texture = new Texture2D(0, 0, TextureFormat.ARGB32, false);36 BindWebGLTexture((int)texture.GetNativeTexturePtr());37}38
xxxxxxxxxx521/*:2 * @plugindesc 对插件的描述3 * 4 * @author 作者5 *6 * @param 插件的第一个参数7 * @desc 描述8 * @default 默认值9 *10 * @param 插件的第一个参数11 * @desc 描述12 * @default 默认值13 * 14 * 15 * 16 * @help17 * 下面这些是对脚本的说明,格式没有强制要求18 * 但是至少应该把使用方法和插件指令列出来。19 *20 */21
22//这个一般都是你的名字,但是没有强制要求,23//只要是一个对象就可以24var Yan = Yan || {};25//下面这个就是来注册插件,格式是固定的26//注意名字要和文件名一样27Yan.Parameters = PluginManager.parameters('你插件的名字');28
29//下面这个就是插件的参数,30Yan.Parameters.参数1 = String(Yan.Parameters['参数'] || '默认值');31Yan.Parameters.参数2 = String(Yan.Parameters['参数2'] || '默认值');32
33//下面这个格式也是固定的34//注意,要是不需要插件指令的话,可以不写35var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;36Game_Interpreter.prototype.pluginCommand = function (command, args) {37 _Game_Interpreter_pluginCommand.call(this, command, args);38 //设计你的插件指令,command就是你插件指令的名字,当然这个可以不止一个,可以用else来创建多个指令39 if (command === '插件指令名字') {40 //参数0就是你的第一个参数41 //比如说插件指令为command 第一个参数为one42 //那么指令就是这样调用的 command one 43 switch (args[0]) {44 case '某':45 //代码46 break;47 case '某某某':48 //代码49 break;50 }51 }52};
字母与数字
| 按键 | 键码 | 按键 | 键码 | 按键 | 键码 | 按键 | 键码 |
|---|---|---|---|---|---|---|---|
| A | 65 | J | 74 | S | 83 | 1 | 49 |
| B | 66 | K | 75 | T | 84 | 2 | 50 |
| C | 67 | L | 76 | U | 85 | 3 | 51 |
| D | 68 | M | 77 | V | 86 | 4 | 52 |
| E | 69 | N | 78 | W | 87 | 5 | 53 |
| F | 70 | O | 79 | X | 88 | 6 | 54 |
| G | 71 | P | 80 | Y | 89 | 7 | 55 |
| H | 72 | Q | 81 | Z | 90 | 8 | 56 |
| I | 73 | R | 82 | 0 | 48 | 9 | 57 |
小键盘和功能键
| 按键 | 键码 | 按键 | 键码 | 按键 | 键码 | 按键 | 键码 |
|---|---|---|---|---|---|---|---|
| 0 | 96 | 8 | 104 | F1 | 112 | F7 | 118 |
| 1 | 97 | 9 | 105 | F2 | 113 | F8 | 119 |
| 2 | 98 | * | 106 | F3 | 114 | F9 | 120 |
| 3 | 99 | + | 107 | F4 | 115 | F10 | 121 |
| 4 | 100 | Enter | 108 | F5 | 116 | F11 | 122 |
| 5 | 101 | - | 109 | F6 | 117 | F12 | 123 |
| 6 | 102 | . | 110 | ||||
| 7 | 103 | / | 111 |
控制键
| 按键 | 键码 | 按键 | 键码 | 按键 | 键码 | 按键 | 键码 |
|---|---|---|---|---|---|---|---|
| BackSpace | 8 | Esc | 27 | Right Arrow | 39 | -_ | 189 |
| Tab | 9 | Spacebar | 32 | Dw Arrow | 40 | .> | 190 |
| Clear | 12 | Page Up | 33 | Insert | 45 | /? | 191 |
| Enter | 13 | Page Down | 34 | Delete | 46 | `~ | 192 |
| Shift | 16 | End | 35 | Num Lock | 144 | [{ | 219 |
| Control | 17 | Home | 36 | ;: | 186 | | | 220 |
| Alt | 18 | Left Arrow | 37 | =+ | 187 | ]} | 221 |
| Cape Lock | 20 | Up Arrow | 38 | ,< | 188 | '" | 222 |
多媒体键
| 按键 | 键码 |
|---|---|
| 音量加 | 175 |
| 音量减 | 174 |
| 停止 | 179 |
| 静音 | 173 |
| 浏览器 | 172 |
| 邮件 | 180 |
| 搜索 | 170 |
| 收藏 | 171 |
| 控制字符 | 功能 |
|---|---|
| \V[n] | 替换为第n个变量的值。 |
| \N[n] | 替换为第 n个角色的名字。 |
| \P[n] | 替换为第n个队伍成员。 |
| \G | 替换为货币单位。 |
| \C[n] | 后方的文字显示为第n号颜色。 |
| \I[n] | 绘制第n个图标。 |
| \{ | 将字体大小增加一级。 |
| \} | 将字体大小减小一级。 |
| \\ | 替换为反斜杠字符。 |
| \$ | 打开金钱窗口。 |
| \. | 等待1/4秒。 |
| \ | |
| \\ | 反斜杠 |
| \! | 等待按键输入。 |
| \> | 立刻显示一行内剩余的文字。 |
| \< | 取消立刻显示文字的效果。 |
| \^ | 显示文本后不等待输入。 |
定义在rpg_core中。Input.keyMapper
MV里面键盘的按键名字和真正的键盘名字是不一样的,一个名字会对应多个实际按钮,所以要特别注意。
| keyName | 实际按钮 |
|---|---|
| 'tab' | tab |
| 'ok' | enter、空格、Z |
| 'shift' | shift |
| 'control' | ctrl、alt |
| 'escape' | esc、小键盘0、insert、X |
| 'pageup' | pageup、Q |
| 'pagedown' | pagedown、W |
| 'left' | 方向键左、小键盘4 |
| 'up' | 方向键上、小键盘8 |
| 'right' | 方向键右、小键盘6 |
| 'down' | 方向键下、小键盘2 |
| 'debug' | F9 |
Scene_Base:所有场景的基类
Scene_Boot:用于初始化整个游戏
Scene_Title:标题界面的场景
Scene_Map:地图界面的场景
Scene_MenuBase:所有菜单类型的基类,也就是游戏中点右键那个菜单
Scene_Menu:主菜单的场景
调用窗口:Window_MenuCommand、Window_Gold、Window_MenuStatus
Scene_ItemBase:技能界面和物品界面的基类
Scene_Item:物品界面
调用窗口:Window_Help
Scene_Skill:技能界面
Scene_Equip:装备界面
Scene_Status:状态界面
Scene_Options:选项界面
Scene_File:储存和读取界面的基类
Scene_Save:储存界面
Scene_Load:读取界面
Scene_GameEnd:游戏结束界面(点击结束游戏时那个界面)
Scene_Shop:商店界面
Scene_Name:姓名输入界面
Scene_Debug:Debug界面
Scene_Battle:战斗场景
Scene_Gameover:游戏结束场景
Window_Base:所有窗体的基类
Window_Selectable:可以用鼠标点击和滑轮滑动的的窗体
Window_Command:选择指令的父类窗口
Window_HorzCommand:The command window for the horizontal selection format.
Window_ItemCategory: The window for selecting a category of items on the item and shop screens.
Window_EquipCommand: The window for selecting a command on the equipment screen.
Window_ShopCommand:展示选择买卖的商店窗口
Window_MenuCommand:主菜单可选指令的窗口,也就是鼠标右键之后,左边那一栏
Window_SkillType: The window for selecting a skill type on the skill screen.
Window_Options:选项屏幕上用于更改各种设置的窗口。(就是选项的窗口)
Window_ChoiceList:对应着事件中显示选项的窗口。
Window_PartyCommand: The window for selecting whether to fight or escape on the battle screen.
Window_ActorCommand:The window for selecting an actor's action on the battle screen.
Window_TitleCommand: The window for selecting New Game/Continue on the title screen.
Window_GameEnd:在游戏结束屏幕上选择“转到标题”的窗口.
Window_MenuStatus:展示角色成员状态的窗口
Window_MenuActor:The window for selecting a target actor on the item and skill screens.
Window_ItemList:The window for selecting an item on the item screen.
Window_EquipItem:The window for selecting an equipment item on the equipment screen.
Window_ShopSell:he window for selecting an item to sell on the shop screen.
Window_EventItem:对应着事件中物品选择处理的窗口
Window_BattleItem:The window for selecting an item to use on the battle screen.
Window_SkillList:The window for selecting a skill on the skill screen.
Window_BattleSkill:The window for selecting a skill to use on the battle screen.
Window_EquipSlot:The window for selecting an equipment slot on the equipment screen.
Window_Status:The window for displaying full status on the status screen.
Window_SavefileList:The window for selecting a save file on the save and load screens.
Window_ShopBuy:The window for selecting an item to buy on the shop screen.
Window_ShopNumber: The window for inputting quantity of items to buy or sell on the shop
// screen.
Window_NameInput:选择玩家姓名的窗口,里面全都是各种字母还有50音。
Window_NumberInput:对应着事件指令数值输入处理的窗口。
Window_BattleLog: The window for displaying battle progress. No frame is displayed, but it is handled as a window for convenience.
Window_BattleStatus: The window for displaying the status of party members on the battle screen.
Window_BattleEnemy:The window for selecting a target enemy on the battle screen.
Window_DebugRange:The window for selecting a block of switches/variables on the debug screen.
Window_DebugEdit:The window for displaying switches and variables on the debug screen.
Window_Help:描述选择物品的窗口
Window_Gold:展示队伍金币数量的窗口
Window_SkillStatus:The window for displaying the skill user's status on the skill screen.
Window_EquipStatus:The window for displaying parameter changes on the equipment screen.
Window_ShopStatus:The window for displaying number of items in possession and the actor's equipment on the shop screen.
Window_NameEdit:编辑角色姓名的窗口,特指上面那个。
Window_Message:展示文字信息的窗口
Window_ScrollText:The window for displaying scrolling text. No frame is displayed, but it
// is handled as a window for convenience.
Window_MapName:展示地图名字的窗口
Sprite_Base:具有显示动画功能的精灵类
Sprite_Character:显示角色的精灵
Sprite_Battler:Sprite_Actor 和 Sprite_Enemy 的父类
Sprite_Actor:显示主角的精灵
Sprite_Enemy:显示敌人
Sprite_StateOverlay:The sprite for displaying an overlay image for a state.
Sprite_Weapon:显示武器攻击图像的精灵
Sprite_Balloon:显示气泡图标的精灵
Sprite_Button:显示按钮的精灵
Sprite_Animation:播放动画的精灵
Sprite_Damage:显示弹出式伤害的精灵
Sprite_StateIcon:展示状态图标的精灵
Sprite_Picture:显示图片的精灵
Sprite_Timer:显示时间的精灵
Sprite_Destination:显示输入区域的精灵
Spriteset_Base:Spriteset_Map 和 Spriteset_Battle 的父类
Spriteset_Map:在地图屏幕上的一组精灵
Spriteset_Battle:战斗屏幕的一组精灵
Game_Temp:用于并不会保存到存档里面的临时数据
Game_System:系统数据
Game_Message:就是用来显示文本或者选择的类
Game_Switches:开关的类
Game_Variables:变量的类
Game_SelfSwitches:独立开关的类
Game_Screen:用于游戏屏幕特效的类,;例如色调更改或者闪屏等
Game_Picture:显示图片的类
Game_Item:
Game_Action:
Game_ActionResult:
Game_BattlerBase:
Game_Battler
Game_Actor
Game_Enemy
Game_Actors:游戏主角们数组的封装类
Game_Unit: Game_Party 和Game_Troop的父类
Game_Party :游戏队伍的类,里面包含着金币和道具等数据
Game_Troop:
Game_Map:
Game_CommonEvent:
Game_CharacterBase:
Game_Character: Game_Player, Game_Follower, GameVehicle和Game_Event的父类
Game_Player
Game_Follower
GameVehicle
Game_Event
Game_Interpreter:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 |
| 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
姓名:闫辰祥
QQ交流群:529245311
B站教程:https://www.bilibili.com/video/BV1Vb4y1q717?spm_id_from=333.999.0.0
教程地址链接:https://klsdf.github.io/
GitHub项目链接:https://github.com/klsdf/klsdf.github.io
2023年4月29日:修复了其中一些错误描述,增加了新api,增加了窗体透明化的方法。
2023年5月4日:将窗体的模板单独提出来了,并补充了自定义窗体的模板,把插件模板放到了附录。补充了很多RPGMV的api。增加了自定义事件触发条件的插件。优化了自定义存档的插件。
本文档收录了RPGMakerMV的若干api,以及nwjs的api。供广大RPGMaker的开发者参考学习。