Project1

标题: 使用技能时,对象如何显示两个动画。 [打印本页]

作者: 小传子    时间: 2012-7-18 17:51
标题: 使用技能时,对象如何显示两个动画。
毫无节操的来提问了,
用的是全动画战斗+23种动画特效。

因为不想拼素材XD,所以想到一个偷懒的办法,
我的思路是:
在game_battler 3里,
例如skill.id == 4 ,
  $game_variables[26] =  1740
  $duixiang = self

= = $duixiang  这个是用来判定对象,变量26是用来设定特定技能里特定附加显示的动画。

于是我在scene_battle 4里某处添加了

if $duixiang != nil
$duixiang.animation_id =  $game_variables[26]
end

但是每一次都是在第一次显示动画并且已经弹出伤害以后,#我试着在弹出伤害的地方修改,结果也只能是轮流显示动画,达到的效果和连续动画播放这个脚本达到的效果一样,
真心愁,求方法求指点。






最佳答案dsu_plus_rewardpost_czw
作者: hys111111    时间: 2012-7-19 12:54
本帖最后由 hys111111 于 2012-7-19 13:07 编辑


if $duixiang != nil
$duixiang.animation_id =  $game_variables[26]
end

好吧,又发现了一些问题……
可以参照RPG::Sprite和Sprite_Battler来参照
def animation什么的来改。
同时@_animation也需要改变。

像def animation改为def 2animation(与其有关的都需要添加并修改)

if $duixiang != nil
$duixiang.animation_id =  $game_variables[26]
end
就可以改成
if $duixiang != nil
$duixiang.2animation_id =  $game_variables[26]
end

作者: 小传子    时间: 2012-7-19 14:13
hys111111 发表于 2012-7-19 12:54
if $duixiang != nil
$duixiang.animation_id =  $game_variables[26]
end

这个我倒是知道,关键添加的地方太多,
看来除了加一个def animation2 之外没什么好办法了。
作者: hys111111    时间: 2012-7-19 16:46
已经写好了,测试一下效果怎么样。

  1. class Spriteset_Battle
  2.   def initialize
  3.     # 生成显示端口
  4.     @viewport1 = Viewport.new(0, 0, 640, 320)
  5.     @viewport2 = Viewport.new(0, 0, 640, 480)
  6.     @viewport3 = Viewport.new(0, 0, 640, 480)
  7.     @viewport4 = Viewport.new(0, 0, 640, 480)
  8.     @viewport2.z = 101
  9.     @viewport3.z = 200
  10.     @viewport4.z = 5000
  11.     # 生成战斗背景活动块
  12.     @battleback_sprite = Sprite.new(@viewport1)
  13.     # 生成敌人活动块
  14.     @enemy_sprites = []
  15.     for enemy in $game_troop.enemies.reverse
  16.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  17.     end
  18.     # 生成敌人活动块
  19.     @actor_sprites = []
  20.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  21.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  22.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  23.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  24.    

  25.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  26.     @new_actor_sprites = []
  27.     @new_actor_sprites.push(RPG::Sprite.new)
  28.     @new_actor_sprites.push(RPG::Sprite.new)
  29.     @new_actor_sprites.push(RPG::Sprite.new)
  30.     @new_actor_sprites.push(RPG::Sprite.new)
  31.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  32.    
  33.    
  34.     # 生成天候
  35.     @weather = RPG::Weather.new(@viewport1)
  36.     # 生成图片活动块
  37.     @picture_sprites = []
  38.     for i in 51..100
  39.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  40.         $game_screen.pictures[i]))
  41.     end
  42.     # 生成计时器块
  43.     @timer_sprite = Sprite_Timer.new
  44.     # 刷新画面
  45.     update
  46.   end
  47.   def update
  48.     # 刷新角色的活动块 (对应角色的替换)
  49.     @actor_sprites[0].battler = $game_party.actors[0]
  50.     @actor_sprites[1].battler = $game_party.actors[1]
  51.     @actor_sprites[2].battler = $game_party.actors[2]
  52.     @actor_sprites[3].battler = $game_party.actors[3]
  53.    
  54.    
  55.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  56.     for aa in 0...@actor_sprites.size
  57.       @new_actor_sprites[aa].x = @actor_sprites[aa].x
  58.       @new_actor_sprites[aa].y = @actor_sprites[aa].y
  59.       @new_actor_sprites[aa].z = @actor_sprites[aa].z
  60.       @new_actor_sprites[aa].ox = @actor_sprites[aa].ox
  61.       @new_actor_sprites[aa].oy = @actor_sprites[aa].oy
  62.       if $duixiang == @actor_sprites[aa].battler
  63.         @new_actor_sprites[aa].animation($data_animations[$game_variables[26]], true)
  64.       end
  65.     end
  66.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  67.    
  68.    
  69.     # 战斗背景的文件名与现在情况有差异的情况下
  70.     if @battleback_name != $game_temp.battleback_name
  71.       @battleback_name = $game_temp.battleback_name
  72.       if @battleback_sprite.bitmap != nil
  73.         @battleback_sprite.bitmap.dispose
  74.       end
  75.       @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  76.       @battleback_sprite.src_rect.set(0, 0, 640, 320)
  77.     end
  78.     # 刷新战斗者的活动块
  79.     for sprite in @enemy_sprites + @actor_sprites
  80.       sprite.update
  81.     end
  82.     # 刷新天气图形
  83.     @weather.type = $game_screen.weather_type
  84.     @weather.max = $game_screen.weather_max
  85.     @weather.update
  86.     # 刷新图片活动块
  87.     for sprite in @picture_sprites
  88.       sprite.update
  89.     end
  90.     # 刷新计时器活动块
  91.     @timer_sprite.update
  92.     # 设置画面的色调与震动位置
  93.     @viewport1.tone = $game_screen.tone
  94.     @viewport1.ox = $game_screen.shake
  95.     # 设置画面的闪烁色
  96.     @viewport4.color = $game_screen.flash_color
  97.     # 刷新显示端口
  98.     @viewport1.update
  99.     @viewport2.update
  100.     @viewport4.update
  101.   end
  102. end
复制代码

作者: 小传子    时间: 2012-7-19 19:14
  1. #==============================================================================
  2. # ■ Spriteset_Battle
  3. #------------------------------------------------------------------------------
  4. #  处理战斗画面的活动块的类。本类在 Scene_Battle 类
  5. # 的内部使用。
  6. #==============================================================================

  7. class Spriteset_Battle
  8.   #--------------------------------------------------------------------------
  9.   # ● 定义实例变量
  10.   #--------------------------------------------------------------------------
  11.   attr_reader   :viewport4                # 敌人方的显示端口
  12.   attr_reader   :viewport2                # 角色方的显示端口
  13.   #--------------------------------------------------------------------------
  14.   # ● 初始化变量
  15.   #--------------------------------------------------------------------------
  16.   def initialize
  17.     # 生成显示端口
  18.     @viewport1 = Viewport.new(0, 0, 640, 480)
  19.     @viewport2 = Viewport.new(0, 0, 640, 480)
  20.     @viewport3 = Viewport.new(0, 0, 640, 480)
  21.     @viewport4 = Viewport.new(0, 0, 640, 480)
  22.     #@viewport1.z = 101
  23.     @viewport2.z = 101
  24.     @viewport3.z = 200
  25.     @viewport4.z = 5000
  26.     # 生成战斗背景活动块
  27.     @battleback_sprite = Sprite.new(@viewport1)
  28.     # 生成敌人活动块
  29.     @enemy_sprites = []
  30.     for enemy in $game_troop.enemies.reverse
  31.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  32.     end
  33.     # 生成敌人活动块
  34.     @actor_sprites = []
  35.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  36.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  37.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  38.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  39.    
  40.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  41.     @new_actor_sprites = []
  42.     @new_actor_sprites.push(RPG::Sprite.new)
  43.     @new_actor_sprites.push(RPG::Sprite.new)
  44.     @new_actor_sprites.push(RPG::Sprite.new)
  45.     @new_actor_sprites.push(RPG::Sprite.new)
  46.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  47.    
  48.    
  49.     # 生成天候
  50.     #@weather = RPG::Weather.new(@viewport1)
  51.     # 生成图片活动块
  52.     @picture_sprites = []
  53.     for i in 51..55
  54.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  55.         $game_screen.pictures[i]))
  56.     end
  57.     # 刷新画面
  58.     update
  59.   end
  60.   #--------------------------------------------------------------------------
  61.   # ● 释放
  62.   #--------------------------------------------------------------------------
  63.   def dispose
  64.     # 如果战斗背景位图存在的情况下就释放
  65.     if @battleback_sprite.bitmap != nil
  66.       @battleback_sprite.bitmap.dispose
  67.     end
  68.     # 释放战斗背景活动块
  69.     @battleback_sprite.dispose
  70.     # 释放敌人活动块、角色活动块
  71.     for sprite in @enemy_sprites + @actor_sprites  
  72.       sprite.dispose
  73.     end
  74.     # 释放天候
  75.     #@weather.dispose
  76.     # 释放图片活动块
  77.     for sprite in @picture_sprites
  78.       sprite.dispose
  79.     end
  80.     # 释放显示端口
  81.     @viewport1.dispose
  82.     @viewport2.dispose
  83.     @viewport3.dispose
  84.     #@viewport4.dispose
  85.   end
  86.   #--------------------------------------------------------------------------
  87.   # ● 显示效果中判定
  88.   #--------------------------------------------------------------------------
  89.   def effect?
  90.     # 如果是在显示效果中的话就返回 true
  91.     for sprite in @enemy_sprites + @actor_sprites
  92.       return true if sprite.effect?
  93.     end
  94.     return false
  95.   end
  96.   
  97.   #--------------------------------------------------------------------------
  98.   # ● 刷新画面
  99.   #--------------------------------------------------------------------------
  100.   def update
  101.     # 刷新角色的活动块 (对应角色的替换)
  102.     @actor_sprites[0].battler = $game_party.actors[0]
  103.     @actor_sprites[1].battler = $game_party.actors[1]
  104.     @actor_sprites[2].battler = $game_party.actors[2]
  105.     @actor_sprites[3].battler = $game_party.actors[3]
  106.    
  107.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  108.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  109.     for aa in 0...@actor_sprites.size

  110.       @new_actor_sprites[aa].x = @actor_sprites[aa].x

  111.       @new_actor_sprites[aa].y = @actor_sprites[aa].y

  112.       @new_actor_sprites[aa].z = @actor_sprites[aa].z

  113.       @new_actor_sprites[aa].ox = @actor_sprites[aa].ox

  114.       @new_actor_sprites[aa].oy = @actor_sprites[aa].oy

  115.       if $duixiang == @actor_sprites[aa].battler
  116.       p "尼玛终于P出来了"
  117.         @new_actor_sprites[aa].animation($data_animations[$game_variables[26]], true)

  118.       end

  119.     end


  120.     #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  121.    
  122.     # 战斗背景的文件名与现在情况有差异的情况下
  123.     if @battleback_name != $game_temp.battleback_name
  124.       @battleback_name = $game_temp.battleback_name
  125.       if @battleback_sprite.bitmap != nil
  126.         @battleback_sprite.bitmap.disposen
  127.       end
  128.       @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  129.       @battleback_sprite.src_rect.set(0, 0, 640, 480)
  130.     end
  131.     # 刷新战斗者的活动块
  132.     for sprite in @enemy_sprites + @actor_sprites
  133.       sprite.update
  134.     end
  135.     # 刷新天气图形
  136.     #@weather.type = $game_screen.weather_type
  137.     #@weather.max = $game_screen.weather_max
  138.     #@weather.update
  139.     # 刷新图片活动块
  140.     for sprite in @picture_sprites
  141.       sprite.update
  142.     end
  143.     # 设置画面的色调与震动位置
  144.     @viewport1.tone = $game_screen.tone
  145.     @viewport1.ox = $game_screen.shake
  146.     # 设置画面的闪烁色
  147.     @viewport4.color = $game_screen.flash_color
  148.     # 刷新显示端口
  149.     @viewport1.update
  150.     @viewport2.update
  151.     @viewport4.update
  152.   end
  153. end
复制代码
这是修改后的脚本,
   if $duixiang == @actor_sprites[aa].battler
      p "尼玛终于P出来了"

P不出来XD。
作者: yagami    时间: 2012-11-2 17:04
本帖最后由 yagami 于 2012-11-2 19:06 编辑

写漏了 请无视= =
作者: yagami    时间: 2012-11-2 19:04
2动画叠加.rar (269.58 KB, 下载次数: 201)
阿尔西斯十字斩采用了2动画叠加 看上去动画时机不统一 是因为我没齐时战斗 所以这不是问题。。���




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1