看到有人需要类似的功能就顺手写了一个插件!
冲刺过长时间,角色会减速。当取消冲刺状态或停止后下来会自动恢复耐力!
冲刺的加速度及减速度会均匀增加,陷入疲惫状态会有气泡提示!
JAVASCRIPT 代码 下载
- /*:
- * Acceleration.js
- * @plugindesc 均匀加减速插件
- * @author 魏玉龙
- * @since 2018.09.15
- * @version 1.0
- *
- * @param speed
- * @desc 加速度
- * @default 0.01
- *
- * @param stamina
- * @desc 角色冲刺持续帧数,为0时可无限时冲刺。
- * @default 600
- *
- */
- (function(){
- var parameters = PluginManager.parameters('Acceleration');
- var speed = Number(parameters['speed'] || 0.01);
- var stamina = Number(parameters['stamina'] || 600);
- var Game_CharacterBase_prototype_initMembers = Game_CharacterBase.prototype.initMembers;
- Game_CharacterBase.prototype.initMembers = function(){
- Game_CharacterBase_prototype_initMembers.call(this);
- this._dashSpeed = 0;
- this._stamina = stamina;
- }
- Game_CharacterBase.prototype.realMoveSpeed = function(){
- returnthis._moveSpeed + this._dashSpeed;
- }
- var Game_CharacterBase_prototype_updateStop = Game_CharacterBase.prototype.updateStop;
- Game_CharacterBase.prototype.updateStop = function(){
- Game_CharacterBase_prototype_updateStop.call(this);
- if(this._dashSpeed != 0){
- this._dashSpeed = 0;
- }
- if(this._stamina < stamina){
- this._stamina++;
- }
- }
- var Game_CharacterBase_prototype_updateMove = Game_CharacterBase.prototype.updateMove;
- Game_CharacterBase.prototype.updateMove = function(){
- Game_CharacterBase_prototype_updateMove.call(this);
- this.updateDashSpeed();
- }
- Game_CharacterBase.prototype.updateDashSpeed = function(){
- if(this.isDashing()){
- if(this._stamina > 0 || stamina == 0){
- this._dashSpeed = Math.min(this._dashSpeed + speed, 1);
- this._stamina > 0 && this._stamina--;
- }else{
- if(this._stamina == 0 && this._dashSpeed == 1){
- this.requestBalloon(7);
- }
- this._dashSpeed = Math.max(this._dashSpeed - speed, -1);
- }
- }else{
- if(this._dashSpeed > 0){
- this._dashSpeed = Math.max(this._dashSpeed - speed, 0);
- }else{
- this._dashSpeed = Math.min(this._dashSpeed + speed, 0);
- }
- if(this._stamina < stamina){
- this._stamina++;
- }
- }
- }
- })();
复制代码
本帖来自P1论坛作者魏玉龙,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址: https://rpg.blue/forum.php?mod=viewthread&tid=410173 若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。 |