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

Project1

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

[已经过期] 在“战斗动态镜头”中,如何让actor一方透明化?

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
64 小时
注册时间
2015-10-13
帖子
5
跳转到指定楼层
1
发表于 2015-10-30 18:48:29 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 风起青岚 于 2015-10-30 18:51 编辑

因为镜头拉近,角色把怪给挡住了
这是大大的脚本……
脚本盲一个,实在惭愧……所以只能求助大大们了
忘了补充句,因为是纵版……

RUBY 代码复制
  1. #==============================================================================
  2. # F14 - 战斗镜头 - By芙蕾娅
  3. #------------------------------------------------------------------------------
  4. #  ★ - 新增  ☆ - 修改  ■ - 删除 ● - 无变更
  5. #==============================================================================
  6. module Freya
  7.   # 镜头帧速,数字越小越快
  8.   Camera_Frame_Speed = 12
  9.   # 镜头放大率,正常大小1.0,默认放大1.2
  10.   Take_Zoom = 1.2
  11.   # 背景增大率,默认0.1
  12.   # 避免默认素材背景在镜头移动后出现黑边所做的处理
  13.   Back_Zoom = 0.1
  14. end
  15. #==============================================================================
  16. # ■ Battle_Camera
  17. #------------------------------------------------------------------------------
  18. #  保存着战斗镜头的讯息
  19. #==============================================================================
  20. class Battle_Camera
  21.   #--------------------------------------------------------------------------
  22.   # ● 定义实例变量
  23.   #--------------------------------------------------------------------------
  24.   attr_accessor :x
  25.   attr_accessor :y
  26.   attr_accessor :zoom
  27.   attr_accessor :new_zoom
  28.   attr_reader :center_width
  29.   attr_reader :center_height
  30.   #--------------------------------------------------------------------------
  31.   # ● 初始化对象
  32.   #--------------------------------------------------------------------------
  33.   def initialize
  34.     @x = @new_x = @center_width = Graphics.width / 2
  35.     @y = @new_y = @center_height = Graphics.height / 1.5
  36.     @zoom = @new_zoom = 1.0
  37.     @frame_speed = Freya::Camera_Frame_Speed
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● 初始化帧率
  41.   #--------------------------------------------------------------------------
  42.   def reset_frame_speed
  43.     @frame_speed = Freya::Camera_Frame_Speed
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 设置镜头瞄准对象
  47.   #--------------------------------------------------------------------------
  48.   def look(target,zoom=nil,speed=nil)
  49.     if target.is_a?(Game_Enemy)
  50.       reset_frame_speed
  51.       @new_x = target.screen_x
  52.       @new_y = target.screen_y
  53.       @new_zoom = zoom unless zoom.nil?
  54.       @frame_speed = speed unless speed.nil?
  55.     end
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ● 将镜头移至中心
  59.   #--------------------------------------------------------------------------
  60.   def center(zoom = 1.0)
  61.     @new_x = @center_width
  62.     @new_y = @center_height
  63.     @new_zoom = zoom
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 计算x坐标
  67.   #--------------------------------------------------------------------------
  68.   def battler_x(battler)
  69.     distance = battler.screen_x - @x
  70.     value = distance * (@zoom - 1.0)
  71.     pos = battler.screen_x - (@x - @center_width)
  72.     return pos + value
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● 计算y坐标
  76.   #--------------------------------------------------------------------------
  77.   def battler_y(battler)
  78.     distance = battler.screen_y - @y
  79.     value = distance * (@zoom - 1.0)
  80.     pos = battler.screen_y - (@y - @center_height)
  81.     return pos + value
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ● 更新画面
  85.   #--------------------------------------------------------------------------
  86.   def update
  87.     if @x != @new_x
  88.       @x = (@new_x - @x > 0) ?
  89.         [@x + move_speed_x, @new_x].min : [@x - move_speed_x, @new_x].max
  90.     end
  91.     if @y != @new_y
  92.       @y = (@new_y - @y > 0) ?
  93.         [@y + move_speed_y, @new_y].min : [@y - move_speed_y, @new_y].max
  94.     end
  95.     if @zoom != @new_zoom
  96.       @zoom = (@new_zoom - @zoom > 0) ?
  97.         [@zoom + zoom_speed, @new_zoom].min : [@zoom - zoom_speed, @new_zoom].max
  98.     end
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 镜头x坐标与指定点x坐标的距离
  102.   #--------------------------------------------------------------------------
  103.   def dis_x
  104.     (@x - @new_x).abs
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 镜头y坐标与指定点y坐标的距离
  108.   #--------------------------------------------------------------------------
  109.   def dis_y
  110.     (@y - @new_y).abs
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 镜头放大率与指定放大率的差距
  114.   #--------------------------------------------------------------------------
  115.   def dis_zoom
  116.     (@zoom - @new_zoom).abs
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 镜头x坐标移动速度
  120.   #--------------------------------------------------------------------------
  121.   def move_speed_x
  122.     return [(dis_x / @frame_speed).to_i, 1].max
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 镜头y坐标移动速度
  126.   #--------------------------------------------------------------------------
  127.   def move_speed_y
  128.     return [(dis_y / @frame_speed).to_i, 1].max
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 镜头缩放速度
  132.   #--------------------------------------------------------------------------
  133.   def zoom_speed
  134.     return [(dis_zoom / @frame_speed), 0.01].max
  135.   end
  136. end
  137. #==============================================================================
  138. # ■ Sprite_Battler
  139. #------------------------------------------------------------------------------
  140. #  显示战斗者的精灵。根据 Game_Battler 类的实例自动变化。
  141. #==============================================================================
  142. class Sprite_Battler < Sprite_Base
  143.   #--------------------------------------------------------------------------
  144.   # ● 定义实例变量
  145.   #--------------------------------------------------------------------------
  146.   attr_accessor :hp_gauge
  147.   #--------------------------------------------------------------------------
  148.   # ☆ 设置动画的精灵
  149.   #--------------------------------------------------------------------------
  150.   def animation_set_sprites(frame)
  151.     cell_data = frame.cell_data
  152.     set_animation_origin
  153.     @ani_sprites.each_with_index do |sprite, i|
  154.       next unless sprite
  155.       pattern = cell_data[i, 0]
  156.       if !pattern || pattern < 0
  157.         sprite.visible = false
  158.         next
  159.       end
  160.       sprite.bitmap = pattern < 100 ? @ani_bitmap1 : @ani_bitmap2
  161.       sprite.visible = true
  162.       sprite.src_rect.set(pattern % 5 * 192,
  163.         pattern % 100 / 5 * 192, 192, 192)
  164.       if @ani_mirror
  165.         sprite.x = @ani_ox - cell_data[i, 1]
  166.         sprite.y = @ani_oy + cell_data[i, 2]
  167.         sprite.angle = (360 - cell_data[i, 4])
  168.         sprite.mirror = (cell_data[i, 5] == 0)
  169.       else
  170.         sprite.x = @ani_ox + cell_data[i, 1]
  171.         sprite.y = @ani_oy + cell_data[i, 2]
  172.         sprite.angle = cell_data[i, 4]
  173.         sprite.mirror = (cell_data[i, 5] == 1)
  174.       end
  175.       sprite.z = self.z + 300 + i
  176.       sprite.ox = 96
  177.       sprite.oy = 96
  178.       sprite.zoom_x = cell_data[i, 3] / 100.0 * self.zoom_x
  179.       sprite.zoom_y = cell_data[i, 3] / 100.0 * self.zoom_y
  180.       sprite.opacity = cell_data[i, 6] * self.opacity / 1.0
  181.       sprite.blend_type = cell_data[i, 7]
  182.     end
  183.   end
  184. end
  185. #==============================================================================
  186. # ■ Spriteset_Battle
  187. #------------------------------------------------------------------------------
  188. #  处理战斗画面的精灵的类。本类在 Scene_Battle 类的内部使用。
  189. #==============================================================================
  190. class Spriteset_Battle
  191.   #--------------------------------------------------------------------------
  192.   # ★ 定义实例变量
  193.   #--------------------------------------------------------------------------
  194.   attr_accessor :battle_camera
  195.   #--------------------------------------------------------------------------
  196.   # ☆ 初始化对象
  197.   #--------------------------------------------------------------------------
  198.   alias initialize_freya_camera initialize
  199.   def initialize
  200.     create_camera
  201.     initialize_freya_camera
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # ★ 创建镜头
  205.   #--------------------------------------------------------------------------
  206.   def create_camera
  207.     @battle_camera = Battle_Camera.new
  208.   end
  209.   #--------------------------------------------------------------------------
  210.   # ☆ 更新画面
  211.   #--------------------------------------------------------------------------
  212.   alias update_freya_camera update
  213.   def update
  214.     update_freya_camera
  215.     update_camera
  216.     actor_opacity = 0
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● 刷新镜头
  220.   #--------------------------------------------------------------------------
  221.   def update_camera
  222.     @battle_camera.update
  223.     update_battleback_position
  224.     update_enemy_position
  225.  
  226.   end
  227.   #--------------------------------------------------------------------------
  228.   # ● 刷新背景坐标
  229.   #--------------------------------------------------------------------------
  230.   def update_battleback_position
  231.     zom = Freya::Take_Zoom + Freya::Back_Zoom
  232.     zoom = @back1_sprite.zoom_x = @back2_sprite.zoom_x = @battle_camera.zoom * zom
  233.     zoom = @back1_sprite.zoom_y = @back2_sprite.zoom_y = @battle_camera.zoom * zom
  234.     x = @back1_sprite.ox
  235.     y = @back1_sprite.oy
  236.     bbx = (x - (@battle_camera.x - @battle_camera.center_width))
  237.     bby = (y - (@battle_camera.y - @battle_camera.center_height))
  238.     @back1_sprite.x = @back2_sprite.x = bbx
  239.     @back1_sprite.y = @back2_sprite.y = bby
  240.   end
  241.   #--------------------------------------------------------------------------
  242.   # ● 刷新敌人坐标
  243.   #--------------------------------------------------------------------------
  244.   def update_enemy_position
  245.     for sprite in @enemy_sprites
  246.       next if sprite.nil? || sprite.battler.nil?
  247.       sprite.zoom_x = @battle_camera.zoom
  248.       sprite.zoom_y = @battle_camera.zoom
  249.       sprite.x = @battle_camera.battler_x(sprite.battler)
  250.       sprite.y = @battle_camera.battler_y(sprite.battler)
  251.       unless sprite.hp_gauge.nil?
  252.         sprite.hp_gauge.x = sprite.x - sprite.hp_gauge.width / 2
  253.         sprite.hp_gauge.y = sprite.y
  254.       end
  255.     end
  256.   end
  257. end
  258. #==============================================================================
  259. # ■ Scene_Battle
  260. #------------------------------------------------------------------------------
  261. #  战斗画面
  262. #==============================================================================
  263. class Scene_Battle < Scene_Base
  264.   #--------------------------------------------------------------------------
  265.   # ★ 获取镜头
  266.   #--------------------------------------------------------------------------
  267.   def camera
  268.     return @spriteset.battle_camera
  269.   end
  270.   #--------------------------------------------------------------------------
  271.   # ☆ 使用技能/物品
  272.   #--------------------------------------------------------------------------
  273.   def use_item
  274.     camera.look(@subject,Freya::Take_Zoom)
  275.     wait(Freya::Camera_Frame_Speed)
  276.     item = @subject.current_action.item
  277.     @log_window.display_use_item(@subject, item)
  278.     @subject.use_item(item)
  279.     refresh_status
  280.     targets = @subject.current_action.make_targets.compact
  281.     camera.look(targets,Freya::Take_Zoom)
  282.     wait(Freya::Camera_Frame_Speed)
  283.     show_animation(targets, item.animation_id)
  284.     targets.each {|target| item.repeats.times { invoke_item(target, item) } }
  285.     camera.center
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # ☆ 应用技能/物品效果
  289.   #--------------------------------------------------------------------------
  290.   alias apply_item_effects_freya_camera apply_item_effects
  291.   def apply_item_effects(target, item)
  292.     camera.look(target, Freya::Take_Zoom)
  293.     wait(Freya::Camera_Frame_Speed)
  294.     apply_item_effects_freya_camera(target, item)
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ☆ 发动反击
  298.   #--------------------------------------------------------------------------
  299.   alias invoke_counter_attack_freya_camera invoke_counter_attack
  300.   def invoke_counter_attack(target, item)
  301.     camera.look(target, Freya::Take_Zoom)
  302.     wait(Freya::Camera_Frame_Speed)
  303.     invoke_counter_attack_freya_camera(target, item)
  304.   end
  305.   #--------------------------------------------------------------------------
  306.   # ☆ 发动反射魔法攻击
  307.   #--------------------------------------------------------------------------
  308.   alias invoke_magic_reflection_freya_camera invoke_magic_reflection
  309.   def invoke_magic_reflection(target, item)
  310.     camera.look(target, Freya::Take_Zoom)
  311.     wait(Freya::Camera_Frame_Speed)
  312.     invoke_magic_reflection_freya_camera(target, item)
  313.   end
  314.   #--------------------------------------------------------------------------
  315.   # ☆ 显示普通动画
  316.   #--------------------------------------------------------------------------
  317.   def show_normal_animation(targets, animation_id, mirror = false)
  318.     animation = $data_animations[animation_id]
  319.     if animation
  320.       camera.center if animation.to_screen?
  321.       targets.each do |target|
  322.         camera.look(target, Freya::Take_Zoom) unless animation.to_screen?
  323.         target.animation_id = animation_id
  324.         target.animation_mirror = mirror
  325.         abs_wait_short unless animation.to_screen?
  326.       end
  327.       abs_wait_short if animation.to_screen?
  328.     end
  329.   end
  330. end







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

本版积分规则

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

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

GMT+8, 2024-11-17 01:38

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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