设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 61|回复: 0

[转载发布] Character Movements (Idle, Walk and Run)

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    7975

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    29957
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    38826

    灌水之王

    发表于 4 天前 | 显示全部楼层 |阅读模式
    Character Movements (Idle, Walk and Run)


    DESCRIPTION:
    Allows for player movement to cycle between 3 character sheets: idle, walk and run.

    EXAMPLE:


    https://www.youtube.com/embed/0_ymbxorNz0

    CODE:

                    Code:       
    1. /*
    2.   <Character Movement>
    3.   v 0.1 - 31 August 2019
    4.   GIT_HUB:
    5.   https://github.com/andrefcasimiro/rpg_maker_mv_js/blob/master/Project1/js/plugins/CharacterMovement.js
    6.   DESCRIPTION:
    7.   Allows for switching between 3 different character sheets: Idle, Walk and Run, according to our movement state.
    8.   INSTRUCTIONS:
    9.   1. Copy and paste plugin.
    10.   2. Choose Idle, Walk and Run character sheets in the plugin's parameters window.
    11.   3. Run game.
    12.   PARAMS:
    13.   @param Actor_{ID}
    14.   ID - must be equal to the actor index in the database
    15.   @param {Pose}_{ID}
    16.   Pose - must be one of the following: 'Idle', 'Walk' or 'Run'
    17.   ID - can be anything as long as you don't repeate @param names
    18. */
    19. /*:
    20. * @plugindesc Allow for player movement to cycle between 3 character sheets: idle, walk and run.
    21. * @author FBU <andrefcasimiro(at)gmail.com>
    22. *
    23. * // ACTOR 1 --------------------------------
    24. * @param Actor_1
    25. *
    26. * @param Idle_Actor1
    27. * @desc "The character set for idle movement"
    28. * @require 1
    29. * @dir img/characters/
    30. * @type file
    31. * @parent Actor_1
    32. *
    33. * @param Walk_Actor1
    34. * @desc "The character set for walk movement"
    35. * @require 1
    36. * @dir img/characters/
    37. * @type file
    38. * @parent Actor_1
    39. *
    40. * @param Run_Actor1
    41. * @desc "The character set for running movement"
    42. * @require 1
    43. * @dir img/characters/
    44. * @type file
    45. * @parent Actor_1
    46. *
    47. */
    48. (function() {
    49.   var Parameters = PluginManager.parameters('CharacterMovement');
    50.   var bank = [];
    51.   Object.keys(Parameters).forEach((parameterKey, index) => {
    52.     var parameterKeyArray = parameterKey.split('_');
    53.     var lastIndex = parameterKeyArray && parameterKeyArray[parameterKeyArray.length - 1];
    54.     var isID = parameterKeyArray[0] === 'Actor' && !isNaN(lastIndex);
    55.     if (isID) {
    56.       bank = bank.concat({
    57.         actor: lastIndex,
    58.         sheet: {},
    59.       });
    60.     } else {
    61.       if (!Parameters[parameterKey]) {
    62.         return;
    63.       }
    64.       var key = parameterKeyArray;
    65.       key.length = key.length - 1;
    66.       key = key.join('_');
    67.       if (bank[bank.length - 1]) {
    68.         bank[bank.length - 1].sheet = {
    69.           ...bank[bank.length - 1].sheet,
    70.           [key]: Parameters[parameterKey],
    71.         };
    72.       }
    73.     }
    74.   })
    75.   var actors = [];
    76.   var isDashing, isWalking = false;
    77.   var isStopped = true;
    78.   var action = 0;
    79.   var _cachedAction;
    80.   var Scene_Map_Create = Scene_Map.prototype.create;
    81.   Scene_Map.prototype.create = function() {
    82.     Scene_Map_Create.call(this);
    83.     actors = bank.map(entry => $gameActors.actor(entry.actor));
    84.   };
    85.   var Scene_Map_Update = Scene_Map.prototype.update;
    86.   Scene_Map.prototype.update = function() {
    87.     Scene_Map_Update.call(this);
    88.     managePlayerMovement();
    89.   };
    90.   var setSheet = function(action) {
    91.     actors.forEach(function (actor, index) {
    92.       if (!Object.keys(bank[index].sheet).length) {
    93.         return;
    94.       }
    95.       actor.setCharacterImage(bank[index].sheet[action], actor.characterIndex())
    96.     });
    97.   }
    98.   var managePlayerMovement = function() {
    99.     isDashing = (!!$gamePlayer.getInputDirection() && $gamePlayer.isDashing()) || !!$gameTemp.isDestinationValid();
    100.     isWalking = !!$gamePlayer.getInputDirection() && !isDashing;
    101.     isStopped = !isWalking && !isDashing;
    102.     if (isStopped) {
    103.       action = 0;
    104.     } else if (isDashing) {
    105.       action = 1;
    106.     } else if (isWalking) {
    107.       action = 2;
    108.     }
    109.     if (action !== _cachedAction) {
    110.       action === 0
    111.         ? setSheet('Idle')
    112.         : action === 2
    113.             ? setSheet('Walk')
    114.             : setSheet('Run');
    115.       $gamePlayer.refresh();
    116.     }
    117.     _cachedAction = action;
    118.   }
    119. })();
    复制代码


    [See also on Github]

    TERMS:
    Can be used freely in commercial and non-commercial projects. No credits required.

    Any code suggestions / improvements are welcome.

    Enjoy!


    本贴来自国际rpgmaker官方论坛作者:fbu处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/character-movements-idle-walk-and-run.112789/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-1 08:32 , Processed in 0.085518 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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