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

相关文章

统一返回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

Kotlin Compose Button 实现长按监听并实现动画效果(完整代码)

《KotlinComposeButton实现长按监听并实现动画效果(完整代码)》想要实现长按按钮开始录音,松开发送的功能,因此为了实现这些功能就需要自己写一个Button来解决问题,下面小编给大... 目录Button 实现原理1. Surface 的作用(关键)2. InteractionSource3.

使用nohup和--remove-source-files在后台运行rsync并记录日志方式

《使用nohup和--remove-source-files在后台运行rsync并记录日志方式》:本文主要介绍使用nohup和--remove-source-files在后台运行rsync并记录日... 目录一、什么是 --remove-source-files?二、示例命令三、命令详解1. nohup2.

使用WPF实现窗口抖动动画效果

《使用WPF实现窗口抖动动画效果》在用户界面设计中,适当的动画反馈可以提升用户体验,尤其是在错误提示、操作失败等场景下,窗口抖动作为一种常见且直观的视觉反馈方式,常用于提醒用户注意当前状态,本文将详细... 目录前言实现思路概述核心代码实现1、 获取目标窗口2、初始化基础位置值3、创建抖动动画4、动画完成后

使用animation.css库快速实现CSS3旋转动画效果

《使用animation.css库快速实现CSS3旋转动画效果》随着Web技术的不断发展,动画效果已经成为了网页设计中不可或缺的一部分,本文将深入探讨animation.css的工作原理,如何使用以及... 目录1. css3动画技术简介2. animation.css库介绍2.1 animation.cs