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

[转载发布] Eli_FixAnalogMove

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

    连续签到: 2 天

    [LV.7]常住居民III

    8038

    主题

    864

    回帖

    3万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

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

    灌水之王

    发表于 5 天前 | 显示全部楼层 |阅读模式

    https://www.youtube.com/embed/i2u5w3qIZYE

    Author Eliaquim
    *No longer supported*
    Requirements

    SAN_AnalogMove.js



    Introduction
    Originally the plugin San_AnalogMove.js has a problem with the direction of diagonal movement:

    • When going Up + Right the player turns his direction to the right, but stills go up.
    • When going Down + Left the player turns his direction to the left, but stills go down.
    • When going Right + Down the player turns his direction to down, but stills go right.
    • When going Left + Up the player turns his direction to up, but stills go left.
    This can causes issues like the player to open doors that are triggered via player touch while he is facing another direction rather than the door.

    Features
    Fix direction problem with SAN_AnalogMove.js

    How to Use
    It's plug and play. Just make sure to put below SAN_AnalogMove.

    Spoiler: Eli_FixAnalogMove.js
                    JavaScript:       
    1. //============================================================================
    2. // Eli_FixAnalogMove.js
    3. //============================================================================
    4. /*:
    5. @plugindesc v1.2 - Fix direction problem with San_AnalogMove.js
    6. @author Eliaquim or Rakuen Zero
    7. @help
    8. ==============================================================================
    9. Introduction
    10. ==============================================================================
    11. Originally the plugin San_AnalogMove.js has a problem with the direction of
    12. diagonal movement:
    13. When going Up + Right the player turns his direction to the right, but
    14. stills go up.
    15. When going Down + Left the player turns his direction to the left, but stills
    16. go down.
    17. When going Right + Down the player turns his direction to down, but stills
    18. go right.
    19. When going Left + Up the player turns his direction to up, but stills go
    20. left.
    21. This can causes issues like the player to open doors that are triggered via
    22. player touch while he is facing another direction rather than the door.
    23. ==============================================================================
    24. Features
    25. ==============================================================================
    26. Fix direction problem with SAN_AnalogMove.js
    27. ==============================================================================
    28. How to use
    29. ==============================================================================
    30. Just make sure to put below SAN_AnalogMove.
    31. In the plugin parameter "Three Buttons Stop Player" leave it as "false" if
    32. you want to use the default behavior of Rm Mv for character movement by
    33. pressing these three directional keys:
    34. up-left-right.
    35. low-up-right.
    36. Set it to "true" if you want the player to stop moving by pressing this
    37. combination of three directional buttons.
    38. ==============================================================================
    39. Terms of Use
    40. ==============================================================================
    41. 1. It is mandatory to give the credits to Eliaquim or Rakuen Zero in the
    42. credits section of your game.
    43. 2. It can be used in free and commercial games.
    44. 3. Do not sell or say that you made this plugin.
    45. 4. Do not redistribute this plugin. Instead, give this link to the download:
    46. ==============================================================================
    47. Special thanks and considerations
    48. ==============================================================================
    49. The plugin is free. However, consider donating if possible.
    50. This can help me with small expenses and motivation! Working with games
    51. in Brazil is very difficult. But don't feel obligated. I hope my small
    52. contribution is also a fuel of hope for you to continue to make your games!
    53. Thank you! Happy Rpg Making!
    54. ==============================================================================
    55. Contact
    56. ==============================================================================
    57. Facebook - https://www.facebook.com/nascmento.eliaquim
    58. RM Web - https://forums.rpgmakerweb.com/index.php?members/eliaquim.123037/
    59. Centro Rpg Maker - https://centrorpg.com/index.php?action=profile
    60. ==============================================================================
    61. Updatelog - Log de atualizações
    62. ==============================================================================
    63. Version 1.3 - 01/02/2020
    64. - Changes in the code for better readability.
    65. Version 1.2 - 10/01/2019
    66. - Inserted plugin parameter as a workaround for another problem of direction
    67. and movement with the player, when three directional buttons are pressed.
    68. - Updated help file!
    69. Thanks to ShadowDragon.
    70. Version 1.1 - 09/29/2019
    71. - Fix the direction problem of the followers.
    72. Version 1.0 - 09/27/2019
    73. - Plugin release!
    74. @param Three Buttons Stop Player
    75. @type boolean
    76. @on Yes
    77. @off No
    78. @desc Stop player movement when 3 directional buttons are pressed at same time.
    79. @default false
    80. */
    81. /*:pt
    82. @plugindesc v1.2 - Conserta um bug de direção que havia no plugin SAN_AnalogMove.
    83. @author Eliaquim or Rakuen Zero
    84. @help
    85. ==============================================================================
    86. Introdução
    87. ==============================================================================
    88. Originalmente o plugin San_AnalogMove.js tem um problema com a direção do
    89. player quando anda na diagonal:
    90. Se apertar cima + direita, o jogador se direciona para direita, mas continua
    91. andando para cima.
    92. Se apertar baixo + esquerda, o jogador se direciona para esquerda, mas
    93. continua andando para baixo.
    94. Se apertar para direita + baixo, o jogador se direciona para baixo, mas
    95. continua andando para direita.
    96. Se apertar esquerda + cima, o jogador se direciona para cima, mas continua
    97. andando para esquerda.
    98. Isso faz com que o jogador entre em uma porta que está acima dele enquanto
    99. olha para a direita, por exemplo.
    100. ==============================================================================
    101. Funcionalidades
    102. ==============================================================================
    103. Conserta um bug de direção que havia no plugin SAN_AnalogMove.
    104. ==============================================================================
    105. Como usar
    106. ==============================================================================
    107. Instale no plugin manager abaixo do SAN_AnalogMove.
    108. No parâmetro de plugin "Three Buttons Stop Player" deixe-o como "false" se
    109. deseja usar o comportamento padrão do Rm Mv para o movimento do personagem
    110. ao pressionar essas três teclas direcionais:
    111. - cima-esquerda-direita.
    112. - baixo-cima-direita.
    113. Coloque-o para "true" se desejar que o jogador pare de se mover ao apertar
    114. essa combinação de três botões direcionais.
    115. ==============================================================================
    116. Termos de uso
    117. ==============================================================================
    118. 1. É obrigatório dar os créditos para Eliaquim ou Rakuen Zero na seção
    119. de créditos do seu jogo.
    120. 2. Pode ser usado em jogos gratuitos e comerciais.
    121. 3. Não venda e nem diga que foi você que fez esse plugin.
    122. 4. Não redistribua esse plugin. Ao invés disso, dê este link para o download:
    123. ==============================================================================
    124. Contato
    125. ==============================================================================
    126. Facebook - https://www.facebook.com/rakuenzero/
    127. Itch io - https://rakuenzero.itch.io/
    128. RM Web - https://forums.rpgmakerweb.com/index.php?members/eliaquim.123037/
    129. Centro Rpg Maker - https://centrorpg.com/index.php?action=profile
    130. ==============================================================================
    131. Log de atualizações
    132. ==============================================================================
    133. Versão 1.3 - 02/01/2020
    134. - Modificações no código para melhor leitura.
    135. Versão 1.2 - 01/10/2019
    136. - Inserido um parâmetro de plugin para corrigir outro problema de direção e
    137. movimento do player quando três botões direcionais são pressionados ao mesmo
    138. tempo.
    139. - Atualização do arquivo de ajuda.
    140. Agradecimentos a ShadowDragon.
    141. Versão 1.1 - 29/09/2019
    142. - Corrigido o problema de direção com os seguidores.
    143. Versão 1.0 - 27/09/2019
    144. - Plugin lançado!
    145. @param Three Buttons Stop Player
    146. @text Três direcionais apertados param o jogador
    147. @type boolean
    148. @on Sim
    149. @off Não
    150. @desc Impede o jogador de se mover quando três botões direcionais são apertados ao mesmo tempo.
    151. @default false
    152. */
    153. "use strict";
    154. var Imported = Imported || {};
    155. Imported.Eli_FixAnalogMove = true;
    156. var Eli = Eli || {};
    157. Eli.FAM = Eli.FAM || {};
    158. if(Imported.SAN_AnalogMove) {
    159. Eli.Parameters = PluginManager.parameters('Eli_FixAnalogMove');
    160. Eli.Param = Eli.Param || {};
    161. Eli.Param.FixAnalogMove = {
    162.     ThreeButtonsStopPlayer: JSON.parse(Eli.Parameters['Three Buttons Stop Player'])
    163. };
    164. // Overwrite default function
    165. CharacterMover.radToDir4 = function(radian) {
    166. };
    167. // Overwrite default function
    168. CharacterMover.dir8ToDir4 = function(dir8, dir4) {
    169. };
    170. function fixNormalDir() {
    171.     const playerDir = $gamePlayer.direction();
    172.         if (playerDir === 8 && Input.isPressed("down")) {
    173.             return $gamePlayer.setDirection(2);
    174.         }
    175.         if (playerDir === 6 && Input.isPressed("left")) {
    176.             return $gamePlayer.setDirection(4);
    177.         }
    178.         if (playerDir === 4 && Input.isPressed("right")) {
    179.             return $gamePlayer.setDirection(6);
    180.         }
    181.         if (playerDir === 2 && Input.isPressed("up")) {
    182.             return $gamePlayer.setDirection(8);
    183.         }
    184. };
    185. function fixDiagonalDir() {
    186.     const playerDir = $gamePlayer.direction();
    187.         if(Input.isPressed("down") && (playerDir === 4 || playerDir === 6)) {      
    188.             return $gamePlayer.setDirection(2);
    189.         }
    190.         if(Input.isPressed("left") && (playerDir === 2 || playerDir === 8)) {      
    191.             return $gamePlayer.setDirection(4);
    192.         }
    193.         if(Input.isPressed("right") && (playerDir === 2 || playerDir === 8)) {      
    194.             return $gamePlayer.setDirection(6);
    195.         }
    196.         if(Input.isPressed("up") && (playerDir === 4 || playerDir === 6)) {      
    197.             return $gamePlayer.setDirection(8);
    198.         }
    199. };
    200. // Fix direction of the player if 3 directional buttons are pressed.
    201. function fixthreeinputs() {
    202.     if (Input.isPressed("up") && Input.isPressed("right") && Input.isPressed("left")) {
    203.         return $gamePlayer.setDirection(8);
    204.     }
    205.     if (Input.isPressed("up") && Input.isPressed("right") && Input.isPressed("down")) {
    206.         return $gamePlayer.setDirection(6);
    207.     }
    208. };
    209. // Player stop moving when 3 directional buttons are pressed.
    210. // Alias
    211. Eli.FAM.Game_Player_canMove = Game_Player.prototype.canMove;
    212.     Game_Player.prototype.canMove = function() {
    213.         if(Eli.Param.FixAnalogMove.ThreeButtonsStopPlayer) {
    214.             if (Input.isPressed("up") && Input.isPressed("right") && (Input.isPressed("left") || Input.isPressed("down"))) {
    215.                 return false;
    216.             }
    217.             if (Input.isPressed("down") && Input.isPressed("right") && Input.isPressed("left")) {
    218.                 return false;
    219.             }
    220.         }
    221.     return Eli.FAM.Game_Player_canMove.call(this);
    222.         
    223. };
    224. function fixFollowerDir(follower) {
    225.     const playerDir = $gamePlayer.direction();
    226.     const playerRealX = $gamePlayer._realX;
    227.     const playerRealY = $gamePlayer._realY;
    228.     const followerRealX = $gamePlayer.followers().followers()[follower]._realX;
    229.     const followerRealY = $gamePlayer.followers().followers()[follower]._realY;
    230.         if(playerDir === 6  && playerRealX > followerRealX) {
    231.             return $gamePlayer.followers().followers()[follower].setDirection(6);
    232.         }
    233.         if(playerDir === 4 && playerRealX < followerRealX) {
    234.             return $gamePlayer.followers().followers()[follower].setDirection(4);
    235.         }
    236.         if(playerDir === 2 && playerRealY > followerRealY) {
    237.             return $gamePlayer.followers().followers()[follower].setDirection(2);
    238.         }
    239.         if(playerDir === 8 && playerRealY < followerRealY) {
    240.             return $gamePlayer.followers().followers()[follower].setDirection(8);
    241.         }
    242. }
    243. // Overwrite default function
    244. FollowerMover.prototype.updateCharacter = function() {
    245.     const precedingCharacter = this.character().precedingCharacter();
    246.     const preChaPosVec = precedingCharacter.posVec();
    247.     const relPosVec = preChaPosVec.sub2(this._posVec);
    248.     this.character().setPosVec(this._posVec);
    249.     this.character().setDirVec(relPosVec);
    250. };
    251. // Alias
    252. Eli.FAM.CharacterMover_update = CharacterMover.prototype.update;
    253.     CharacterMover.prototype.update = function() {
    254.         Eli.FAM.CharacterMover_update.call(this);
    255.         const flw = [0, 1, 2];
    256.         fixNormalDir();
    257.         fixDiagonalDir();
    258.         if(!Eli.Param.FixAnalogMove.ThreeButtonsStopPlayer) {
    259.             fixthreeinputs();
    260.         }
    261.         // else {
    262.         //     Eli.FAM.Game_Player_canMove();
    263.         // }
    264.         flw.forEach(fixFollowerDir);
    265. };
    266. } else {
    267.     throw new Error('San_AnalogMove.js is missing!');
    268. };
    复制代码



    Credit and Thanks

    No need to credit me.
    For the original one, give credits to Sanshiro.
    It can be used in free and commercial games.
    Do not sell or say that you made this plugin.

    Thanks for Sanshiro for this amazing pixel movement plugin!


    Update Log
    SpoilerVersion 1.3 - 01/02/2020
    - Changes in the code for better readability.
    Version 1.2 - 10/01/2019
    - Inserted plugin parameter as a workaround for another problem of direction
    and movement with the player, when three directional buttons are pressed.
    - Updated help file!
    Thanks to ShadowDragon.
    Version 1.1 - 09/29/2019
    - Fix the direction problem of the followers.
    Version 1.0 - 09/27/2019
    - Plugin release!






    本贴来自国际rpgmaker官方论坛作者:Eliaquim处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/eli_fixanalogmove.113732/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-1 10:44 , Processed in 0.150206 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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