RPG Maker MV角色战斗动画记录

2024-06-03 07:28

本文主要是介绍RPG Maker MV角色战斗动画记录,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

角色战斗动画记录

  • 角色战斗状态
    • 判断的语句
    • 赋值
  • 战斗管理
  • 战斗精灵
    • 创建精灵
    • 进行角色的更新

角色战斗状态

角色的战斗状态是由 Game_Battler 类中的 _actionState 属性的字符串决定的,它有哪些值呢?

  • undecided 未确定或者说是操作状态
  • inputting 输入
  • waiting 等待
  • acting 活跃
  • done 完成

其他类通过调用 Game_Battler 中判断的方法来确定部分值是否一致来操作人物的精灵。

判断的语句

Game_Battler.prototype.isUndecided = function() {return this._actionState === 'undecided';
};Game_Battler.prototype.isInputting = function() {return this._actionState === 'inputting';
};Game_Battler.prototype.isWaiting = function() {return this._actionState === 'waiting';
};Game_Battler.prototype.isActing = function() {return this._actionState === 'acting';
};

赋值

Game_Battler.prototype.setActionState = function(actionState) {this._actionState = actionState;this.requestMotionRefresh();
};

完成赋值后进行调用请求运动的更新方法,将运动刷新改变成 true 来控制刷新。

战斗管理

/** 战斗管理_变更演员* @param {Object} newActorIndex 新演员索引* @param {Object} lastActorActionState 最后一个演员操作状态*/
BattleManager.changeActor = function(newActorIndex, lastActorActionState) {var lastActor = this.actor();this._actorIndex = newActorIndex;var newActor = this.actor();if (lastActor) {lastActor.setActionState(lastActorActionState);}if (newActor) {newActor.setActionState('inputting');}
};

战斗精灵

Sprite_Actor.MOTIONS = {walk:     { index: 0,  loop: true  },//向前迈出一步wait:     { index: 1,  loop: true  },//正常待机chant:    { index: 2,  loop: true  },//吟唱待机guard:    { index: 3,  loop: true  },//保护damage:   { index: 4,  loop: false },//损坏evade:    { index: 5,  loop: false },//闪避thrust:   { index: 6,  loop: false },//刺swing:    { index: 7,  loop: false },//摆动missile:  { index: 8,  loop: false },//投掷skill:    { index: 9,  loop: false },//一般技能spell:    { index: 10, loop: false },//魔法item:     { index: 11, loop: false },//物品使用escape:   { index: 12, loop: true  },//逃跑victory:  { index: 13, loop: true  },//胜利dying:    { index: 14, loop: true  },//重伤abnormal: { index: 15, loop: true  },//异常状态sleep:    { index: 16, loop: true  },//睡眠dead:     { index: 17, loop: true  }//死亡
};

这里面可以看到对应战斗时精灵是有哪些动作的!
图片及链接:
战斗精灵
有兴趣的可以到这个图片连接的网站上看看!!!

创建精灵

Sprite_Actor.prototype.initMembers = function() {Sprite_Battler.prototype.initMembers.call(this);this._battlerName = '';this._motion = null;this._motionCount = 0;this._pattern = 0;this.createShadowSprite();this.createWeaponSprite();this.createMainSprite();this.createStateSprite();
};

这里面初始化了角色的成员,从上到下有战斗图片的名称,运动的动作变量,动作的运动计数,图案数字信息,创建了创建阴影精灵、武器精灵、主体精灵、状态精灵

进行角色的更新

本次探究不会太过深入及条理性的发出代码,请见谅!!!

Sprite_Actor.prototype.update = function() {Sprite_Battler.prototype.update.call(this);this.updateShadow();if (this._actor) {this.updateMotion();}
};
Sprite_Battler.prototype.update = function() {Sprite_Base.prototype.update.call(this);if (this._battler) {this.updateMain();this.updateAnimation();this.updateDamagePopup();this.updateSelectionEffect();} else {this.bitmap = null;}
};

父类调用了更新主体的方法,更新动画的方法等,自己调用了更新阴影,和运动的方法。
父类调用的主体中调用了角色类的图片更新方法,更新使用的对应角色的图片,之后调用帧的更新方法,更新了每个动作中对应的动画效果,之后更新移动和坐标点。

//更新图片
Sprite_Actor.prototype.updateBitmap = function() {Sprite_Battler.prototype.updateBitmap.call(this);var name = this._actor.battlerName();if (this._battlerName !== name) {this._battlerName = name;this._mainSprite.bitmap = ImageManager.loadSvActor(name);}
};

更新战斗的角色的图片

//更新战斗帧
Sprite_Actor.prototype.updateFrame = function() {Sprite_Battler.prototype.updateFrame.call(this);var bitmap = this._mainSprite.bitmap;if (bitmap) {var motionIndex = this._motion ? this._motion.index : 0;var pattern = this._pattern < 3 ? this._pattern : 1;var cw = bitmap.width / 9;var ch = bitmap.height / 6;var cx = Math.floor(motionIndex / 6) * 3 + pattern;var cy = motionIndex % 6;this._mainSprite.setFrame(cx * cw, cy * ch, cw, ch);}
};

**motionIndex **中是角色所在对应动作的帧,**pattern 是动作的动画帧,可以看到每个动作是3个动画帧,cx是横向的三个动作坐标,cy是纵向的6个动作的坐标。
其中可以看到
pattern **没有进行改变的值,那它是在哪改变的呢?

//更新运动
Sprite_Actor.prototype.updateMotion = function() {this.setupMotion();this.setupWeaponAnimation();if (this._actor.isMotionRefreshRequested()) {this.refreshMotion();this._actor.clearMotion();}this.updateMotionCount();
};
//更新该运动的计数
Sprite_Actor.prototype.updateMotionCount = function() {if (this._motion && ++this._motionCount >= this.motionSpeed()) {if (this._motion.loop) {this._pattern = (this._pattern + 1) % 4;} else if (this._pattern < 2) {this._pattern++;} else {this.refreshMotion();}this._motionCount = 0;}
};
//运动休眠
Sprite_Actor.prototype.motionSpeed = function() {return 12;
};

就是这里面进行了数字的变更。
最后需要根据操作变更动作,这里用了角色的刷新运动

//刷新运动
Sprite_Actor.prototype.refreshMotion = function() {var actor = this._actor;var motionGuard = Sprite_Actor.MOTIONS['guard'];if (actor) {if (this._motion === motionGuard && !BattleManager.isInputting()) {return;}var stateMotion = actor.stateMotionIndex();if (actor.isInputting() || actor.isActing()) {this.startMotion('walk');console.log("前进表演")} else if (stateMotion === 3) {this.startMotion('dead');} else if (stateMotion === 2) {this.startMotion('sleep');console.log("睡眠")} else if (actor.isChanting()) {this.startMotion('chant');console.log("魔法等待")} else if (actor.isGuard() || actor.isGuardWaiting()) {this.startMotion('guard');console.log("保护等待")} else if (stateMotion === 1) {this.startMotion('abnormal');console.log("异常状态")} else if (actor.isDying()) {this.startMotion('dying');console.log("重伤")} else if (actor.isUndecided()) {//是否犹豫(等待)this.startMotion('walk');console.log("是否犹豫")} else {this.startMotion('wait');console.log("前进1")}}
};

这些部分就行主要的精灵操作了。
看着这么些代码,觉得这游戏开发上很多东西还是耦合的挺多的,因此多事需要进行很多东西的修改也是发现是一件挺麻烦的一件事。

这篇关于RPG Maker MV角色战斗动画记录的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1026339

相关文章

在Spring Boot中集成RabbitMQ的实战记录

《在SpringBoot中集成RabbitMQ的实战记录》本文介绍SpringBoot集成RabbitMQ的步骤,涵盖配置连接、消息发送与接收,并对比两种定义Exchange与队列的方式:手动声明(... 目录前言准备工作1. 安装 RabbitMQ2. 消息发送者(Producer)配置1. 创建 Spr

k8s上运行的mysql、mariadb数据库的备份记录(支持x86和arm两种架构)

《k8s上运行的mysql、mariadb数据库的备份记录(支持x86和arm两种架构)》本文记录在K8s上运行的MySQL/MariaDB备份方案,通过工具容器执行mysqldump,结合定时任务实... 目录前言一、获取需要备份的数据库的信息二、备份步骤1.准备工作(X86)1.准备工作(arm)2.手

SpringBoot3应用中集成和使用Spring Retry的实践记录

《SpringBoot3应用中集成和使用SpringRetry的实践记录》SpringRetry为SpringBoot3提供重试机制,支持注解和编程式两种方式,可配置重试策略与监听器,适用于临时性故... 目录1. 简介2. 环境准备3. 使用方式3.1 注解方式 基础使用自定义重试策略失败恢复机制注意事项

Python UV安装、升级、卸载详细步骤记录

《PythonUV安装、升级、卸载详细步骤记录》:本文主要介绍PythonUV安装、升级、卸载的详细步骤,uv是Astral推出的下一代Python包与项目管理器,主打单一可执行文件、极致性能... 目录安装检查升级设置自动补全卸载UV 命令总结 官方文档详见:https://docs.astral.sh/

统一返回JsonResult踩坑的记录

《统一返回JsonResult踩坑的记录》:本文主要介绍统一返回JsonResult踩坑的记录,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录统一返回jsonResult踩坑定义了一个统一返回类在使用时,JsonResult没有get/set方法时响应总结统一返回

Go学习记录之runtime包深入解析

《Go学习记录之runtime包深入解析》Go语言runtime包管理运行时环境,涵盖goroutine调度、内存分配、垃圾回收、类型信息等核心功能,:本文主要介绍Go学习记录之runtime包的... 目录前言:一、runtime包内容学习1、作用:① Goroutine和并发控制:② 垃圾回收:③ 栈和

java对接海康摄像头的完整步骤记录

《java对接海康摄像头的完整步骤记录》在Java中调用海康威视摄像头通常需要使用海康威视提供的SDK,下面这篇文章主要给大家介绍了关于java对接海康摄像头的完整步骤,文中通过代码介绍的非常详细,需... 目录一、开发环境准备二、实现Java调用设备接口(一)加载动态链接库(二)结构体、接口重定义1.类型

apache的commons-pool2原理与使用实践记录

《apache的commons-pool2原理与使用实践记录》ApacheCommonsPool2是一个高效的对象池化框架,通过复用昂贵资源(如数据库连接、线程、网络连接)优化系统性能,这篇文章主... 目录一、核心原理与组件二、使用步骤详解(以数据库连接池为例)三、高级配置与优化四、典型应用场景五、注意事

SpringBoot实现文件记录日志及日志文件自动归档和压缩

《SpringBoot实现文件记录日志及日志文件自动归档和压缩》Logback是Java日志框架,通过Logger收集日志并经Appender输出至控制台、文件等,SpringBoot配置logbac... 目录1、什么是Logback2、SpringBoot实现文件记录日志,日志文件自动归档和压缩2.1、

qtcreater配置opencv遇到的坑及实践记录

《qtcreater配置opencv遇到的坑及实践记录》我配置opencv不管是按照网上的教程还是deepseek发现都有些问题,下面是我的配置方法以及实践成功的心得,感兴趣的朋友跟随小编一起看看吧... 目录电脑环境下载环境变量配置qmake加入外部库测试配置我配置opencv不管是按照网上的教程还是de