设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1529|回复: 6
打印 上一主题 下一主题

[已经解决] 如何在战斗中人物被选中时播放动画

[复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
423 小时
注册时间
2011-3-11
帖子
299
跳转到指定楼层
1
发表于 2013-4-4 22:52:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
请问如何在战斗中,每个人物(包括主角和敌人)、在主角回合开始时、以及敌人被选中时(就是默认情况下那把剑的图标出现)
显示一段动画、
就是仙五战斗系统中、在敌人或主角下画一个圈。
那个画圈的动画我已做好、现在只差显示动画
请问如何解决。

Lv5.捕梦者

梦石
0
星屑
32137
在线时间
5084 小时
注册时间
2012-11-19
帖子
4877

开拓者

2
发表于 2013-4-4 23:20:22 | 只看该作者
本帖最后由 芯☆淡茹水 于 2013-4-4 23:21 编辑

  试验了一下,话说播放动画好像不能中途中断吧,所以选择对象时,要等动画播放完才能接受按键操作。
试做了一个,只有选择敌人,但按键很费劲,待高手解决
  1. class Arrow_Base < Sprite
  2.   def update
  3.     # 刷新点灭记数
  4.     @blink_count = (@blink_count + 1) % 8
  5.     # 设置传送源矩形
  6.     if @blink_count < 4
  7.       self.src_rect.set(128, 96, 32, 32)
  8.     else
  9.       self.src_rect.set(160, 96, 32, 32)
  10.     end
  11.     target = $game_troop.enemies[@index]
  12.     if target.exist?
  13.       # 设置动画 ID
  14.       target.animation_id = 2
  15.     end
  16.     # 刷新帮助文本 (update_help 定义了继承目标)
  17.     if @help_window != nil
  18.       update_help
  19.     end
  20.   end
  21. end
复制代码
14行为动画ID
xp vx va mv  va mz 各类型脚本/插件定制
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
193 小时
注册时间
2013-3-24
帖子
448
3
发表于 2013-4-5 02:22:31 | 只看该作者
本帖最后由 joe5491 于 2013-4-5 02:23 编辑

寫好了~自己看看效果~
p.s.參數記得調整
  1. #==========================================================
  2. #★ 選中動畫 -by joe59491
  3. #===========================================================

  4. #========參數設定===========================================
  5. $choise_animation=2      #選中動畫編號
  6. $empty_animation=999  #一個空動畫的編號動畫編號(必須在資料庫裡)
  7. # p.s.如果空動畫的編號是在資料庫設定大小外的話,戰鬥畫面會卡住
  8. #===========================================================

  9. class Scene_Battle
  10.   
  11.   def update_phase3_enemy_select
  12.     # 更新敵人箭頭
  13.    @old_ene_arr_idx=@enemy_arrow.index
  14.     loop do
  15.       if [email protected]?
  16.         $game_troop.enemies[@enemy_arrow.index].animation_id = $choise_animation
  17.       end
  18.       if @enemy_arrow.index != @old_ene_arr_idx
  19.         $game_troop.enemies[@old_ene_arr_idx].animation_id = $empty_animation
  20.         $game_troop.enemies[@enemy_arrow.index].animation_id = $choise_animation
  21.       end
  22.       @old_ene_arr_idx = @enemy_arrow.index
  23.       @spriteset.update
  24.       @enemy_arrow.update
  25.       $game_system.update
  26.       $game_screen.update
  27.       Input.update
  28.       Graphics.update
  29.       # 按下 B 鍵的情況下
  30.       if Input.trigger?(Input::B)
  31.         $game_troop.enemies[@enemy_arrow.index].animation_id = $empty_animation
  32.         @choise = 0
  33.         break
  34.       end
  35.       # 按下 C 鍵的情況下
  36.       if Input.trigger?(Input::C)
  37.         $game_troop.enemies[@enemy_arrow.index].animation_id = $empty_animation
  38.         @choise=1
  39.         break
  40.       end
  41.     end
  42.     @spriteset.update
  43.     if @choise == 0
  44.       # 演奏取消 SE
  45.       $game_system.se_play($data_system.cancel_se)
  46.       # 選擇敵人結束
  47.       end_enemy_select
  48.       return
  49.     else
  50.       # 演奏確定 SE
  51.       $game_system.se_play($data_system.decision_se)
  52.       # 設定行動
  53.       @active_battler.current_action.target_index = @enemy_arrow.index
  54.       # 選擇敵人結束
  55.       end_enemy_select
  56.       # 顯示技能視窗中的情況下
  57.       if @skill_window != nil
  58.         # 結束技能選擇
  59.         end_skill_select
  60.       end
  61.       # 顯示物品視窗的情況下
  62.       if @item_window != nil
  63.         # 結束物品選擇
  64.         end_item_select
  65.       end
  66.       # 轉到下一位角色的指令輸入
  67.       phase3_next_actor
  68.     end
  69.   end
  70.   
  71.   def update_phase3_actor_select
  72.     @old_act_arr_idx=@actor_arrow.index
  73.     loop do
  74.       if [email protected]?
  75.         $game_party.actors[@actor_arrow.index].animation_id = $choise_animation
  76.       end
  77.       if @actor_arrow.index != @old_act_arr_idx
  78.         $game_party.actors[@old_act_arr_idx].animation_id = $empty_animation
  79.         $game_party.actors[@actor_arrow.index].animation_id = $choise_animation
  80.       end
  81.       @old_act_arr_idx = @actor_arrow.index
  82.       @spriteset.update
  83.       @actor_arrow.update
  84.       $game_system.update
  85.       $game_screen.update
  86.       Input.update
  87.       Graphics.update      
  88.       # 按下 B 鍵的情況下
  89.       if Input.trigger?(Input::B)
  90.         $game_party.actors[@actor_arrow.index].animation_id = $empty_animation
  91.         @choise = 0
  92.         break
  93.       end
  94.       # 按下 C 鍵的情況下
  95.       if Input.trigger?(Input::C)
  96.         $game_party.actors[@actor_arrow.index].animation_id = $empty_animation
  97.         @choise = 1
  98.         break
  99.       end
  100.     end
  101.     if @choise == 0
  102.       # 演奏取消 SE
  103.       $game_system.se_play($data_system.cancel_se)
  104.       # 選擇角色結束
  105.       end_actor_select
  106.       return
  107.     else
  108.       # 演奏確定 SE
  109.       $game_system.se_play($data_system.decision_se)
  110.       # 設定行動
  111.       @active_battler.current_action.target_index = @actor_arrow.index
  112.       # 選擇角色結束
  113.       end_actor_select
  114.       # 顯示技能視窗中的情況下
  115.       if @skill_window != nil
  116.         # 結束技能選擇
  117.         end_skill_select
  118.       end
  119.       # 顯示物品視窗的情況下
  120.       if @item_window != nil
  121.         # 結束物品選擇
  122.         end_item_select
  123.       end
  124.       # 轉到下一位角色的指令輸入
  125.       phase3_next_actor
  126.     end
  127.   end
  128.   
  129.   def update_phase3_basic_command
  130.     loop do
  131.       if [email protected]?
  132.         $game_party.actors[@actor_index].animation_id = $choise_animation
  133.       end
  134.       @spriteset.update
  135.       @actor_command_window.update
  136.       $game_system.update
  137.       $game_screen.update
  138.       Input.update
  139.       Graphics.update      
  140.       if Input.trigger?(Input::B)
  141.         $game_party.actors[@actor_index].animation_id = $empty_animation
  142.         @choise=0
  143.         break
  144.       end
  145.       if Input.trigger?(Input::C)
  146.         $game_party.actors[@actor_index].animation_id = $empty_animation
  147.         @choise=1
  148.         break
  149.       end
  150.     end
  151.     if @choise == 0
  152.       # 演奏取消 SE
  153.       $game_system.se_play($data_system.cancel_se)
  154.       # 轉向前一個角色的指令輸入
  155.       phase3_prior_actor
  156.       return
  157.     else   
  158.       # 角色指令視窗游標位置分之
  159.       case @actor_command_window.index
  160.       when 0  # 攻擊
  161.         # 演奏確定 SE
  162.         $game_system.se_play($data_system.decision_se)
  163.         # 設定行動
  164.         @active_battler.current_action.kind = 0
  165.         @active_battler.current_action.basic = 0
  166.         # 開始選擇敵人
  167.         start_enemy_select
  168.       when 1  # 技能
  169.         # 演奏確定 SE
  170.         $game_system.se_play($data_system.decision_se)
  171.         # 設定行動
  172.         @active_battler.current_action.kind = 1
  173.         # 開始選擇技能
  174.         start_skill_select
  175.       when 2  # 防禦
  176.         # 演奏確定 SE
  177.         $game_system.se_play($data_system.decision_se)
  178.         # 設定行動
  179.         @active_battler.current_action.kind = 0
  180.         @active_battler.current_action.basic = 1
  181.         # 轉向下一位角色的指令輸入
  182.         phase3_next_actor
  183.       when 3  # 物品
  184.         # 演奏確定 SE
  185.         $game_system.se_play($data_system.decision_se)
  186.         # 設定行動
  187.         @active_battler.current_action.kind = 2
  188.         # 開始選擇物品
  189.         start_item_select
  190.       end
  191.       return
  192.     end
  193.   end
  194. end
复制代码
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
423 小时
注册时间
2011-3-11
帖子
299
4
 楼主| 发表于 2013-4-5 18:00:48 | 只看该作者
joe5491 发表于 2013-4-5 02:22
寫好了~自己看看效果~
p.s.參數記得調整

其他都可以、只是人物一旦被选中、这个的动画就会一直被重复播放、我的本意是只播放一次就可以了、请问如何修改?
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
193 小时
注册时间
2013-3-24
帖子
448
5
发表于 2013-4-5 21:40:04 | 只看该作者
在看看效果吧~
  1. #==========================================================
  2. #★ 選中動畫v2 -by joe59491
  3. #===========================================================

  4. #========參數設定===========================================
  5. $choise_animation=2      #選中動畫編號
  6. $empty_animation=999  #一個空動畫的編號動畫編號(必須在資料庫裡)
  7. # p.s.如果空動畫的編號是在資料庫設定大小外的話,戰鬥畫面會卡住
  8. #===========================================================

  9. class Scene_Battle
  10.   
  11.   def update_phase3_enemy_select
  12.     # 更新敵人箭頭
  13.     @old_ene_arr_idx=@enemy_arrow.index
  14.     $game_troop.enemies[@enemy_arrow.index].animation_id = $choise_animation
  15.     loop do
  16.       if @enemy_arrow.index != @old_ene_arr_idx
  17.         $game_troop.enemies[@old_ene_arr_idx].animation_id = $empty_animation
  18.         $game_troop.enemies[@enemy_arrow.index].animation_id = $choise_animation
  19.       end
  20.       @old_ene_arr_idx = @enemy_arrow.index
  21.       @spriteset.update
  22.       @enemy_arrow.update
  23.       $game_system.update
  24.       $game_screen.update
  25.       Input.update
  26.       Graphics.update
  27.       # 按下 B 鍵的情況下
  28.       if Input.trigger?(Input::B)
  29.         $game_troop.enemies[@enemy_arrow.index].animation_id = $empty_animation
  30.         @choise = 0
  31.         break
  32.       end
  33.       # 按下 C 鍵的情況下
  34.       if Input.trigger?(Input::C)
  35.         $game_troop.enemies[@enemy_arrow.index].animation_id = $empty_animation
  36.         @choise=1
  37.         break
  38.       end
  39.     end
  40.     @spriteset.update
  41.     if @choise == 0
  42.       # 演奏取消 SE
  43.       $game_system.se_play($data_system.cancel_se)
  44.       # 選擇敵人結束
  45.       end_enemy_select
  46.       return
  47.     else
  48.       # 演奏確定 SE
  49.       $game_system.se_play($data_system.decision_se)
  50.       # 設定行動
  51.       @active_battler.current_action.target_index = @enemy_arrow.index
  52.       # 選擇敵人結束
  53.       end_enemy_select
  54.       # 顯示技能視窗中的情況下
  55.       if @skill_window != nil
  56.         # 結束技能選擇
  57.         end_skill_select
  58.       end
  59.       # 顯示物品視窗的情況下
  60.       if @item_window != nil
  61.         # 結束物品選擇
  62.         end_item_select
  63.       end
  64.       # 轉到下一位角色的指令輸入
  65.       phase3_next_actor
  66.     end
  67.   end
  68.   
  69.   def update_phase3_actor_select
  70.     @old_act_arr_idx=@actor_arrow.index
  71.     $game_party.actors[@actor_arrow.index].animation_id = $choise_animation
  72.     loop do
  73.       if @actor_arrow.index != @old_act_arr_idx
  74.         $game_party.actors[@old_act_arr_idx].animation_id = $empty_animation
  75.         $game_party.actors[@actor_arrow.index].animation_id = $choise_animation
  76.       end
  77.       @old_act_arr_idx = @actor_arrow.index
  78.       @spriteset.update
  79.       @actor_arrow.update
  80.       $game_system.update
  81.       $game_screen.update
  82.       Input.update
  83.       Graphics.update      
  84.       # 按下 B 鍵的情況下
  85.       if Input.trigger?(Input::B)
  86.         $game_party.actors[@actor_arrow.index].animation_id = $empty_animation
  87.         @choise = 0
  88.         break
  89.       end
  90.       # 按下 C 鍵的情況下
  91.       if Input.trigger?(Input::C)
  92.         $game_party.actors[@actor_arrow.index].animation_id = $empty_animation
  93.         @choise = 1
  94.         break
  95.       end
  96.     end
  97.     if @choise == 0
  98.       # 演奏取消 SE
  99.       $game_system.se_play($data_system.cancel_se)
  100.       # 選擇角色結束
  101.       end_actor_select
  102.       return
  103.     else
  104.       # 演奏確定 SE
  105.       $game_system.se_play($data_system.decision_se)
  106.       # 設定行動
  107.       @active_battler.current_action.target_index = @actor_arrow.index
  108.       # 選擇角色結束
  109.       end_actor_select
  110.       # 顯示技能視窗中的情況下
  111.       if @skill_window != nil
  112.         # 結束技能選擇
  113.         end_skill_select
  114.       end
  115.       # 顯示物品視窗的情況下
  116.       if @item_window != nil
  117.         # 結束物品選擇
  118.         end_item_select
  119.       end
  120.       # 轉到下一位角色的指令輸入
  121.       phase3_next_actor
  122.     end
  123.   end
  124.   
  125.   def update_phase3_basic_command
  126.     $game_party.actors[@actor_index].animation_id = $choise_animation
  127.     loop do
  128.       @spriteset.update
  129.       @actor_command_window.update
  130.       $game_system.update
  131.       $game_screen.update
  132.       Input.update
  133.       Graphics.update      
  134.       if Input.trigger?(Input::B)
  135.         $game_party.actors[@actor_index].animation_id = $empty_animation
  136.         @choise=0
  137.         break
  138.       end
  139.       if Input.trigger?(Input::C)
  140.         $game_party.actors[@actor_index].animation_id = $empty_animation
  141.         @choise=1
  142.         break
  143.       end
  144.     end
  145.     if @choise == 0
  146.       # 演奏取消 SE
  147.       $game_system.se_play($data_system.cancel_se)
  148.       # 轉向前一個角色的指令輸入
  149.       phase3_prior_actor
  150.       return
  151.     else   
  152.       # 角色指令視窗游標位置分之
  153.       case @actor_command_window.index
  154.       when 0  # 攻擊
  155.         # 演奏確定 SE
  156.         $game_system.se_play($data_system.decision_se)
  157.         # 設定行動
  158.         @active_battler.current_action.kind = 0
  159.         @active_battler.current_action.basic = 0
  160.         # 開始選擇敵人
  161.         start_enemy_select
  162.       when 1  # 技能
  163.         # 演奏確定 SE
  164.         $game_system.se_play($data_system.decision_se)
  165.         # 設定行動
  166.         @active_battler.current_action.kind = 1
  167.         # 開始選擇技能
  168.         start_skill_select
  169.       when 2  # 防禦
  170.         # 演奏確定 SE
  171.         $game_system.se_play($data_system.decision_se)
  172.         # 設定行動
  173.         @active_battler.current_action.kind = 0
  174.         @active_battler.current_action.basic = 1
  175.         # 轉向下一位角色的指令輸入
  176.         phase3_next_actor
  177.       when 3  # 物品
  178.         # 演奏確定 SE
  179.         $game_system.se_play($data_system.decision_se)
  180.         # 設定行動
  181.         @active_battler.current_action.kind = 2
  182.         # 開始選擇物品
  183.         start_item_select
  184.       end
  185.       return
  186.     end
  187.   end
  188. end
复制代码

评分

参与人数 1梦石 +1 收起 理由
hcm + 1 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
49
在线时间
423 小时
注册时间
2011-3-11
帖子
299
6
 楼主| 发表于 2013-4-13 21:35:35 | 只看该作者
joe5491 发表于 2013-4-5 21:40
在看看效果吧~

可以了!谢谢您。
由于是学生党,只有星期六能上网,这么晚才回复,实在抱歉。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-24 01:48

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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