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

Project1

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

[已经过期] 如何实现战斗中镜头跟随和放缩的效果

[复制链接]

Lv3.寻梦者

梦石
0
星屑
4471
在线时间
1053 小时
注册时间
2013-3-28
帖子
390

开拓者

跳转到指定楼层
1
发表于 2021-9-20 23:10:00 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 陈大帅帅帅哥 于 2021-9-26 20:26 编辑

选择行动时镜头移向角色,播放攻击动画时镜头移向目标
记得以前见过这样的脚本,但是现在找不到了

已经自行解决了,以下为找到的脚本
RUBY 代码复制
  1. # ▼▲▼ XRXS_BP 8. バトルバック・Full-View+可動カメラ ver.2 ▼▲▼ built 102523
  2. # by 桜雅 在土
  3.  
  4. #==============================================================================
  5. # □ カスタマイズポイント
  6. #==============================================================================
  7. module XRXS_BP8
  8.   #
  9.   # カメラ移動スピード基準値 (基本的に小さいほうが速い)
  10.   #
  11.   SPEED = 8
  12.   #
  13.   # XGAサイズを設定
  14.   #
  15.   GA = Rect.new(-192, -144, 1024, 768)
  16. end
  17. #------------------------------------------------------------------------------
  18. # ▽ 可動カメラの動き設定
  19. #------------------------------------------------------------------------------
  20. class Scene_Battle
  21.   #--------------------------------------------------------------------------
  22.   # ● パーティコマンドフェーズ開始
  23.   #--------------------------------------------------------------------------
  24.   alias xrxs_bp8_start_phase2 start_phase2
  25.   def start_phase2
  26.     # カメラ:センタリング
  27.     $xcam.centering
  28.     # 呼び戻す
  29.     xrxs_bp8_start_phase2
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択)
  33.   #--------------------------------------------------------------------------
  34.   alias xrxs_bp8_update_phase3_enemy_select update_phase3_enemy_select
  35.   def update_phase3_enemy_select
  36.     # 現在選択中のエネミーを取得
  37.     enemy = $game_troop.enemies[@enemy_arrow.index]
  38.     # カメラ:注目
  39.     #$xcam.watch_at(enemy.x)
  40.     $xcam.watch(enemy)
  41.     # 戻す
  42.     xrxs_bp8_update_phase3_enemy_select
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # ● エネミー選択終了
  46.   #--------------------------------------------------------------------------
  47.   alias xrxs_bp8_end_enemy_select end_enemy_select
  48.   def end_enemy_select
  49.     # カメラ:センタリング
  50.     $xcam.centering
  51.     # 呼び戻す
  52.     xrxs_bp8_end_enemy_select
  53.   end
  54.   #--------------------------------------------------------------------------
  55.   # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  56.   #--------------------------------------------------------------------------
  57.   alias xrxs_bp8_update_phase4_step2 update_phase4_step2
  58.   def update_phase4_step2
  59.     # 戻す
  60.     xrxs_bp8_update_phase4_step2
  61.     # ステップ 3 に移行する予定の場合
  62.     if @phase4_step == 3
  63.       # アクティブなバトラーがバトルフィールドに居る場合
  64.       if @active_battler.in_battlefield?
  65.         # カメラ:注目
  66.         $xcam.watch(@active_battler)
  67.       end
  68.     end
  69.   end
  70.   #--------------------------------------------------------------------------
  71.   # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション)
  72.   #--------------------------------------------------------------------------
  73.   alias xrxs_bp8_update_phase4_step3 update_phase4_step3
  74.   def update_phase4_step3
  75.     # 戻す
  76.     xrxs_bp8_update_phase4_step3
  77.     # カメラターゲットとなりうるターゲットの X 平均値を計算
  78.     x_average  = 0
  79.     number     = 0
  80.     cam_target = nil
  81.     for target in @target_battlers
  82.       if target.in_battlefield?
  83.         x_average += target.x
  84.         number    += 1
  85.         cam_target = target
  86.       end
  87.     end
  88.     # カメラターゲットが見つかった場合
  89.     if number > 0
  90.       # もし対象アニメが「位置:画面」の場合
  91.       animation = $data_animations[@animation2_id]
  92.       if animation != nil and animation.position == 3
  93.         # カメラ:センタリング
  94.         $xcam.centering
  95.         # カメラ:ズームアウト
  96.         $xcam.zoomout
  97.       elsif number == 1
  98.         # カメラ:注目
  99.         $xcam.watch(cam_target)
  100.       else
  101.         # カメラ:指定 X 位置を注目
  102.         $xcam.watch_at(x_average / number)
  103.       end
  104.     end
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● アフターバトルフェーズ開始
  108.   #--------------------------------------------------------------------------
  109.   alias xrxs_bp8_start_phase5 start_phase5
  110.   def start_phase5
  111.     # カメラ:センタリング
  112.     $xcam.centering
  113.     # 呼び戻す
  114.     xrxs_bp8_start_phase5
  115.   end
  116. end
  117. #------------------------------------------------------------------------------
  118. # カスタマイズポイントここまで
  119. #==============================================================================
  120.  
  121. #------------------------------------------------------------------------------
  122. #
  123. #
  124. #
  125. #    ▽ 可動カメラ システム ▽
  126. #
  127. #
  128. #
  129. #==============================================================================
  130. # □ XCam
  131. #------------------------------------------------------------------------------
  132. #   可動カメラを扱うクラスです。
  133. #==============================================================================
  134. class XCam
  135.   #--------------------------------------------------------------------------
  136.   # ○ 公開インスタンス変数
  137.   #--------------------------------------------------------------------------
  138.   attr_reader   :x
  139.   attr_reader   :y
  140.   attr_reader   :z
  141.   attr_accessor :x_destination
  142.   attr_accessor :y_destination
  143.   attr_accessor :z_destination
  144.   attr_accessor :watch_battler
  145.   attr_accessor :freeze_count
  146.   #--------------------------------------------------------------------------
  147.   # ○ オブジェクト初期化
  148.   #--------------------------------------------------------------------------
  149.   def initialize
  150.     # カメラ初期位置決定
  151.     @x = 320
  152.     @y = 240
  153.     @z = 295
  154.     # カメラ:センタリング
  155.     self.centering
  156.     # 初期化
  157.     @freeze_count = 0
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ○ フレーム更新
  161.   #--------------------------------------------------------------------------
  162.   def update
  163.     @moved = false
  164.     # カメラ位置の更新
  165.     if @freeze_count > 0
  166.       # フリーズカウントを減らす
  167.       @freeze_count -= 1
  168.     else
  169.       # スピードの取得
  170.       speed = XRXS_BP8::SPEED
  171.       # カメラ: Z 座標 (優先)
  172.       z_dest = @z_destination
  173.       if @z != z_dest
  174.         @z = slide(@z, z_dest, 1, 74, 296)
  175.         @moved = true
  176.       end
  177.       # カメラ: X 座標
  178.       x_dest = @watch_battler == nil ? @x_destination : @watch_battler.x
  179.       if @x != x_dest
  180.         maximum = 192 * (296 - @z) / 111 + 320
  181.         minimum = 640 - maximum
  182.         @x = slide(@x, x_dest, 8, minimum, maximum)
  183.         @moved = true
  184.       end
  185.       # カメラ: Y 座標
  186.       y_dest = @watch_battler == nil ? @y_destination : 88 + @watch_battler.y/2
  187.       if @y != y_dest
  188.         maximum = 164 * (296 - @z) / 111 + 240
  189.         minimum = 480 - maximum
  190.         @y = slide(@y, y_dest, 4, minimum, maximum)
  191.         @moved = true
  192.       end
  193.     end
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # ○ スライド (現在地・目的地から行くべき現在地を返す)
  197.   #--------------------------------------------------------------------------
  198.   def slide(from, to, move_min, to_min, to_max)
  199.     # 移動距離を計算
  200.     distance = (to - from).abs
  201.     # 結果を判別
  202.     if distance < move_min
  203.       result = to
  204.     else
  205.       sign   = from > to ? -1 : 1
  206.       result = from + sign * [distance / XRXS_BP8::SPEED, move_min].max
  207.     end
  208.     # 範囲によって返却
  209.     return [[result, to_min].max, to_max].min
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ○ 動いたかどうか?
  213.   #--------------------------------------------------------------------------
  214.   def moved?
  215.     return @moved
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ○ センタリング
  219.   #--------------------------------------------------------------------------
  220.   def centering
  221.     @watch_battler = nil
  222.     @x_destination = 320
  223.     @y_destination = 240
  224.     @z_destination = 185
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # ○ ズームアウト
  228.   #--------------------------------------------------------------------------
  229.   def zoomout
  230.     @z_destination = 222
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ○ バトラーを注目
  234.   #--------------------------------------------------------------------------
  235.   def watch(battler)
  236.     @watch_battler = battler
  237.     @z_destination = 176
  238.   end
  239.   #--------------------------------------------------------------------------
  240.   # ○ 指定 X 位置を注目
  241.   #--------------------------------------------------------------------------
  242.   def watch_at(x)
  243.     @watch_battler = nil
  244.     @x_destination =   x
  245.     @y_destination = 240
  246.     @z_destination = 185
  247.   end
  248. end
  249. #==============================================================================
  250. # ■ Game_Battler
  251. #==============================================================================
  252. class Game_Battler
  253.   #--------------------------------------------------------------------------
  254.   # ○ 公開インスタンス変数
  255.   #--------------------------------------------------------------------------
  256.   attr_reader   :x                        # バトルフィールド 横 位置(+が右 )
  257.   attr_reader   :y                        # バトルフィールド 高さ 位置(+が下 )
  258.   attr_reader   :z                        # バトルフィールド奥行き位置(+が手前)
  259.   attr_accessor :zoom                     # 現在のズーム倍率
  260.   #--------------------------------------------------------------------------
  261.   # ○ バトルフィールド上に居るか?
  262.   #--------------------------------------------------------------------------
  263.   def in_battlefield?
  264.     return false
  265.   end
  266. end
  267. #==============================================================================
  268. # ■ Game_Enemy
  269. #==============================================================================
  270. class Game_Enemy < Game_Battler
  271.   #--------------------------------------------------------------------------
  272.   # ○ バトルフィールド上に居るか? [オーバーライド]
  273.   #--------------------------------------------------------------------------
  274.   def in_battlefield?
  275.     return true
  276.   end
  277.   #--------------------------------------------------------------------------
  278.   # ● オブジェクト初期化
  279.   #--------------------------------------------------------------------------
  280.   alias xrxs_bp8_initialize initialize
  281.   def initialize(troop_id, member_index)
  282.     # 初期化
  283.     @z    = 0
  284.     @zoom = 1.00
  285.     # 呼び戻す
  286.     xrxs_bp8_initialize(troop_id, member_index)
  287.   end
  288.   #--------------------------------------------------------------------------
  289.   # ● バトル画面 X 座標の取得
  290.   #--------------------------------------------------------------------------
  291.   alias x screen_x
  292.   def screen_x
  293.     return self.x if $xcam == nil
  294.     return 320 + (self.x - 320) * self.zoom + (320 - $xcam.x)
  295.   end
  296.   #--------------------------------------------------------------------------
  297.   # ● バトル画面 Y 座標の取得
  298.   #--------------------------------------------------------------------------
  299.   alias y screen_y
  300.   def screen_y
  301.     return self.y if $xcam == nil
  302.     return 240 + (self.y - 240) * self.zoom + (240 - $xcam.y)
  303.   end
  304. end
  305. #==============================================================================
  306. # ■ Spriteset_Battle
  307. #==============================================================================
  308. class Spriteset_Battle
  309.   #--------------------------------------------------------------------------
  310.   # ○ フレーム更新 (可動カメラ)
  311.   #--------------------------------------------------------------------------
  312.   def update_xcam
  313.     # カメラ位置が動いた場合
  314.     if $xcam.moved?
  315.       # カメラ位置からズーム率を計算
  316.       zoom = 185.00 / $xcam.z
  317.       # 背景の設定更新
  318.       @battleback_sprite.zoom_x = zoom
  319.       @battleback_sprite.zoom_y = zoom
  320.       @battleback_sprite.x      = -($xcam.x - 320) * zoom - 512 * (zoom - 1)
  321.       @battleback_sprite.y      = -($xcam.y - 240) * zoom - 384 * (zoom - 1)
  322.     end
  323.   end
  324. end
  325. #==============================================================================
  326. # --- バトラースプライト・可動カメラ適用 ---
  327. #==============================================================================
  328. module XRXS_Cam_Deal
  329.   def update
  330.     # 呼び戻す
  331.     super
  332.     # バトラーがバトルフィールドにいない場合は終了
  333.     return if @battler == nil or not @battler.in_battlefield?
  334.     # カメラ Z 座標の取得
  335.     cam_z = $xcam == nil ? 185 : $xcam.z
  336.     #
  337.     # ズーム率の変更
  338.     # ( スプライト座標の再設定は元のメソッドに任せる )
  339.     #
  340.     zoom = 1.00 * 185 / (cam_z - @battler.z)
  341.     self.zoom_x   = zoom
  342.     self.zoom_y   = zoom
  343.     @battler.zoom = zoom
  344.   end
  345. end
  346. class Sprite_Battler < RPG::Sprite
  347.   include XRXS_Cam_Deal
  348. end
  349. #==============================================================================
  350. # --- ダメージフォロー モジュール ---
  351. #==============================================================================
  352. module XRXS_DamageFollow
  353.   def update
  354.     # 呼び戻す
  355.     super
  356.     # カメラが存在しない場合
  357.     return if $xcam == nil
  358.     # バトラーが nil またはバトルフィールドにいない場合
  359.     return if @battler == nil or not @battler.in_battlefield?
  360.     # 直前カメラ位置から、移動量を算出
  361.     x_moved = @last_cam_x == nil ? 0 : $xcam.x - @last_cam_x
  362.     y_moved = @last_cam_y == nil ? 0 : $xcam.y - @last_cam_y
  363.     # ダメージスプライト配列の作成
  364.     damage_sprites  = [@_damage_sprite]
  365.     damage_sprites += @damage_sprites if @damage_sprites != nil
  366.     # カメラをフォロー
  367.     for sprite in damage_sprites
  368.       next if sprite == nil
  369.       next if sprite.disposed?
  370.       sprite.x -= x_moved
  371.       sprite.y -= y_moved
  372.     end
  373.     # 直前カメラ位置の保持
  374.     @last_cam_x = $xcam.x
  375.     @last_cam_y = $xcam.y
  376.   end
  377. end
  378. class Sprite_Battler < RPG::Sprite
  379.   include XRXS_DamageFollow
  380. end
  381. #==============================================================================
  382. # ■ Scene_Battle
  383. #==============================================================================
  384. class Scene_Battle
  385.   #--------------------------------------------------------------------------
  386.   # ● メイン処理
  387.   #--------------------------------------------------------------------------
  388.   alias xrxs_bp8_main main
  389.   def main
  390.     # 可動カメラの生成
  391.     $xcam = XCam.new
  392.     # 戻す
  393.     xrxs_bp8_main
  394.     # 可動カメラの解放
  395.     $xcam = nil
  396.   end
  397.   #--------------------------------------------------------------------------
  398.   # ● フレーム更新
  399.   #--------------------------------------------------------------------------
  400.   alias xrxs_bp8_update update
  401.   def update
  402.     # 可動カメラのフレーム更新
  403.     $xcam.update
  404.     # 呼び戻す
  405.     xrxs_bp8_update
  406.   end
  407. end
  408.  
  409.  
  410.  
  411. #------------------------------------------------------------------------------
  412. #
  413. #
  414. #
  415. #    ▽ Full-View システム ▽
  416. #
  417. #
  418. #
  419. #==============================================================================
  420. # ■ Spriteset_Battle
  421. #==============================================================================
  422. class Spriteset_Battle
  423.   #--------------------------------------------------------------------------
  424.   # ● オブジェクト初期化
  425.   #--------------------------------------------------------------------------
  426.   alias xrxs_bp8_initialize initialize
  427.   def initialize
  428.     # 呼び戻す
  429.     xrxs_bp8_initialize
  430.     # グラフィックスアレイを取得
  431.     ga = XRXS_BP8::GA
  432.     # ビューポート 0 を作成
  433.     @viewport0 = Viewport.new(ga.x, ga.y, ga.width, ga.height)
  434.     @viewport0.z  = 0
  435.     # ビューポート 1 の設定を変更
  436.     @viewport1.z += 1
  437.     @viewport1.rect.height = 480
  438.     # バトルバックスプライトを再作成 (ビューポート 0 を使用)
  439.     @battleback_sprite.dispose
  440.     @battleback_sprite = Sprite.new(@viewport0)
  441.     @battleback_name = ""
  442.     # バトルバックのフレーム更新
  443.     update_battleback
  444.   end
  445.   #--------------------------------------------------------------------------
  446.   # ● 解放
  447.   #--------------------------------------------------------------------------
  448.   alias xrxs_bp8_dispose dispose
  449.   def dispose
  450.     # 呼び戻す
  451.     xrxs_bp8_dispose
  452.     # ビューポートを解放
  453.     @viewport0.dispose
  454.   end
  455.   #--------------------------------------------------------------------------
  456.   # ● フレーム更新
  457.   #--------------------------------------------------------------------------
  458.   alias xrxs_bp8_update update
  459.   def update
  460.     # フレーム更新 (バトルバック)
  461.     update_battleback
  462.     # フレーム更新 (可動カメラ)
  463.     update_xcam if defined? update_xcam
  464.     # 呼び戻す
  465.     xrxs_bp8_update
  466.     # 画面のシェイク位置を設定
  467.     @viewport0.ox = $game_screen.shake if @viewport0 != nil
  468.   end
  469.   #--------------------------------------------------------------------------
  470.   # ○ フレーム更新 (バトルバック)
  471.   #--------------------------------------------------------------------------
  472.   def update_battleback
  473.     # バトルバックのファイル名が現在のものと違う場合
  474.     if @battleback_name != $game_temp.battleback_name
  475.       @battleback_name = $game_temp.battleback_name
  476.       if @battleback_sprite.bitmap != nil
  477.         @battleback_sprite.bitmap.dispose
  478.       end
  479.       # グラフィックスアレイを取得
  480.       ga = XRXS_BP8::GA
  481.       # バトルバックの取得と拡大
  482.       bg   = RPG::Cache.battleback(@battleback_name)
  483.       xga  = Bitmap.new(ga.width, ga.height)
  484.       xga.stretch_blt(xga.rect, bg, bg.rect)
  485.       # XGAをバトルバックに設定
  486.       @battleback_sprite.bitmap = xga
  487.     end
  488.   end
  489. end
  490. #==============================================================================
  491. # ---「戦闘中の"画面"アニメの位置修正」モジュール ---
  492. #==============================================================================
  493. module XRXS_FullScreen_AnimationOffset
  494.   def animation_set_sprites(sprites, cell_data, position)
  495.     super
  496.     for i in 0..15
  497.       sprite = sprites[i]
  498.       pattern = cell_data[i, 0]
  499.       if sprite == nil or pattern == nil or pattern == -1
  500.         next
  501.       end
  502.       if position == 3
  503.         if self.viewport != nil
  504.           sprite.y = 160 # この一行だけ変更
  505.         end
  506.       end
  507.     end
  508.   end
  509. end
  510. class Sprite_Battler < RPG::Sprite
  511.   include XRXS_FullScreen_AnimationOffset
  512. end

Lv3.寻梦者

梦石
0
星屑
2851
在线时间
446 小时
注册时间
2016-9-26
帖子
1222
2
发表于 2021-9-21 00:15:41 | 只看该作者
玩家移动时,玩家的角色是玩家的角色。
对方移动时,对方的角色才是玩家的角色。

点评

啊这,不太明白和问题有什么关系(  发表于 2021-9-21 17:54
回复 支持 反对

使用道具 举报

Lv5.捕梦者 (版主)

梦石
1
星屑
23963
在线时间
3338 小时
注册时间
2011-7-8
帖子
3925

开拓者

3
发表于 2021-9-23 20:25:43 | 只看该作者
本质上是把画面上的全部内容进行了放大和平移……要改的东西还挺多的吧
熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
14106
在线时间
2141 小时
注册时间
2019-1-24
帖子
1121

R考场第七期纪念奖

4
发表于 2021-9-24 18:31:35 | 只看该作者
试试这个看是不是你要的。

RTAB初版.zip

226.81 KB, 下载次数: 18

点评

RTAB试过了,个人能力不足,没法把缩放单独提取出来。  发表于 2021-9-26 20:25
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-23 16:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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