查看: 68|回复: 0

[转载发布] 【Akahara】画面动画只播放一次

[复制链接]
  • TA的每日心情
    开心
    前天 00:56
  • 签到天数: 33 天

    连续签到: 1 天

    [LV.5]常住居民I

    2022

    主题

    32

    回帖

    7144

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5074
    OK点
    16
    积分
    7144
    发表于 同元一千年二月十八日(春) | 显示全部楼层 |阅读模式
    修复一个问题

    RUBY 代码
    1. #==============================================================================
    2. # ■ 画面动画只播放一次 By:Akahara
    3. #------------------------------------------------------------------------------
    4. #
    5. #  由于进行了重定义建议放在插件脚本位置较前的地方
    6. #
    7. #  解决了多个敌人播放画面动画会重叠好几次的问题
    8. #  第一个目标不变
    9. #  其他目标时“闪烁目标”,“隐藏目标”会照常播放
    10. #  “播放se”,“闪烁画面”不会播放
    11. #
    12. #------------------------------------------------------------------------------
    13. class Game_Battler < Game_BattlerBase
    14.   attr_accessor :hide_animation
    15.   alias akahara_hidea_initialize initialize
    16.   def initialize
    17.     @hide_animation = false
    18.     akahara_hidea_initialize
    19.   end
    20. end
    21. class Sprite_Base < Sprite
    22.   def start_animation(animation, mirror = false, hide = false)
    23.     dispose_animation
    24.     @hide = hide
    25.     @animation = animation
    26.     if@animation
    27.       @ani_mirror = mirror
    28.       set_animation_rate
    29.       @ani_duration = @animation.frame_max * @ani_rate + 1
    30.       load_animation_bitmap
    31.       make_animation_sprites
    32.       set_animation_origin
    33.     end
    34.   end
    35.   def update_animation
    36.     returnunless animation?
    37.     @ani_duration -= 1
    38.     if@ani_duration % @ani_rate == 0
    39.       if@ani_duration > 0
    40.         frame_index = @animation.frame_max
    41.         frame_index -= (@ani_duration + @ani_rate - 1) / @ani_rate
    42.         animation_set_sprites(@animation.frames[frame_index])unless@hide == true
    43.         @animation.timings.eachdo |timing|
    44.           animation_process_timing(timing, @hide)if timing.frame == frame_index
    45.         end
    46.       else
    47.         end_animation
    48.       end
    49.     end
    50.   end
    51.   def animation_process_timing(timing, hide = false)
    52.     timing.se.playunless hide == true || @ani_duplicated
    53.     case timing.flash_scope
    54.     when1
    55.       self.flash(timing.flash_color, timing.flash_duration * @ani_rate)
    56.     when2
    57.       if viewport && !@ani_duplicated
    58.         viewport.flash(timing.flash_color, timing.flash_duration * @ani_rate)unless hide == true
    59.       end
    60.     when3
    61.       self.flash(nil, timing.flash_duration * @ani_rate)
    62.     end
    63.   end
    64. end
    65. class Sprite_Battler < Sprite_Base
    66.   def setup_new_animation
    67.     if@battler.animation_id > 0
    68.       animation = $data_animations[@battler.animation_id]
    69.       mirror = @battler.animation_mirror
    70.       hide = @battler.hide_animation
    71.       start_animation(animation, mirror, hide)
    72.       @battler.hide_animation = false
    73.       @battler.animation_id = 0
    74.     end
    75.   end
    76. end
    77. class Scene_Battle < Scene_Base
    78.   def show_normal_animation(targets, animation_id, mirror = false)
    79.     animation = $data_animations[animation_id]
    80.     if animation
    81.       targets.each_with_indexdo |target,index|
    82.         target.hide_animation = trueif animation.to_screen? && target != targets[0]
    83.         target.animation_id = animation_id
    84.         target.animation_mirror = mirror
    85.         abs_wait_short unless animation.to_screen?
    86.       end
    87.       abs_wait_short if animation.to_screen?
    88.     end
    89.   end
    90. end
    复制代码


    解决了rm默认播放画面动画多个敌人会重复播放导致重叠很丑的问题
                 本帖来自P1论坛作者sxjkjly8010,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=494736  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

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

    GMT+8, 2024-4-30 11:05 , Processed in 0.046329 second(s), 41 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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