查看: 1677|回复: 1

[已经解决] 跳过标题和光标前动画脚本能否共存?

[复制链接]
梦石
0
星屑
50
在线时间
130 小时
注册时间
2016-1-14
回帖
106
发表于 2016-5-4 17:31:57 | 显示全部楼层 |阅读模式

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

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

×
最近想在游戏中插入光标前面的动画,但我又用了跳过标题的脚本,所以两者产生了冲突。

敢问一下,是否可以改一下脚本,让这两者能够共存呢?!

光标的位置显示动画脚本:
  1. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  2. #_/    ◆ カーソルアニメーション - KMS_CursorAnimation ◆ VX Ace ◆
  3. #_/    ◇ Last update : 2012/02/19 (TOMY@Kamesoft) ◇
  4. #_/----------------------------------------------------------------------------
  5. #_/  光标的位置显示动画。
  6. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

  7. #==============================================================================
  8. # ★ 設定項目 - BEGIN Setting ★
  9. #==============================================================================

  10. module KMS_CursorAnimation
  11.   # ◆ 最初からカーソルアニメを表示する
  12.   #  true  : タイトルなどでもアニメを表示する。
  13.   #  false : ゲーム中に明示的にオンするまで表示しない。
  14.   DEFAULT_ANIMATION = true

  15.   # ◆ アニメファイル名
  16.   #  "Graphics/System" から読み込む。
  17.   ANIMATION_FILE = "CursorAnimation"
  18.   # ◆ 动画的框架数
  19.   FRAME_COUNT    = 10
  20.   # ◆ アニメーションウェイト
  21.   #  数值越大,动画越晚。
  22.   ANIMATION_WAIT = 4

  23.   # ◆ 不透明度
  24.   OPACITY       = 255
  25.   # ◆ 合成方法
  26.   #  0..通常  1..加算  2..減算
  27.   BLEND_TYPE    = 1
  28.   # ◆ 基準位置
  29.   #  0..上  1..中央  2..下
  30.   BASE_POSITION = 0
  31.   # ◆ 表示位置補正 [x, y]
  32.   POSITION_REV  = [0, -10]
  33. end

  34. #==============================================================================
  35. # ☆ 設定ここまで - END Setting ☆
  36. #==============================================================================

  37. $kms_imported = {} if $kms_imported == nil
  38. $kms_imported["CursorAnimation"] = true

  39. # *****************************************************************************

  40. #==============================================================================
  41. # □ KMS_Commands
  42. #==============================================================================

  43. module KMS_Commands
  44.   module_function
  45.   #--------------------------------------------------------------------------
  46.   # ○ カーソルアニメを表示
  47.   #--------------------------------------------------------------------------
  48.   def show_cursor_animation
  49.     $game_system.cursor_animation_visible = true
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ○ カーソルアニメを非表示
  53.   #--------------------------------------------------------------------------
  54.   def hide_cursor_animation
  55.     $game_system.cursor_animation_visible = false
  56.   end
  57.   #--------------------------------------------------------------------------
  58.   # ○ カーソルアニメ表示状態の取得
  59.   #--------------------------------------------------------------------------
  60.   def cursor_animation_visible?
  61.     return $game_system.cursor_animation_visible
  62.   end
  63. end

  64. #==============================================================================
  65. # ■ Game_Interpreter
  66. #==============================================================================

  67. class Game_Interpreter
  68.   # イベントコマンドから直接コマンドを叩けるようにする
  69.   include KMS_Commands
  70. end

  71. #==============================================================================
  72. # ■ Window_Base
  73. #==============================================================================

  74. class Window_Base < Window
  75.   #--------------------------------------------------------------------------
  76.   # ○ クラス変数
  77.   #--------------------------------------------------------------------------
  78.   @@__cursor_animation = nil  # カーソルアニメ
  79.   #--------------------------------------------------------------------------
  80.   # ● オブジェクト初期化
  81.   #     x       : ウィンドウの X 座標
  82.   #     y       : ウィンドウの Y 座標
  83.   #     width   : ウィンドウの幅
  84.   #     height  : ウィンドウの高さ
  85.   #--------------------------------------------------------------------------
  86.   alias initialize_KMS_CursorAnimation initialize
  87.   def initialize(x, y, width, height)
  88.     initialize_KMS_CursorAnimation(x, y, width, height)

  89.     @@__cursor_animation.add_window(self)
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 解放
  93.   #--------------------------------------------------------------------------
  94.   unless method_defined?(:dispose_KMS_CursorAnimation)
  95.     alias dispose_KMS_CursorAnimation dispose
  96.   end
  97.   def dispose
  98.     @@__cursor_animation.remove_window(self)

  99.     dispose_KMS_CursorAnimation
  100.   end
  101.   #--------------------------------------------------------------------------
  102.   # ○ カーソルアニメを生成
  103.   #--------------------------------------------------------------------------
  104.   def self.create_cursor_animation
  105.     @@__cursor_animation = Cursor_Animation.new
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ○ カーソルアニメを破棄
  109.   #--------------------------------------------------------------------------
  110.   def self.dispose_cursor_animation
  111.     @@__cursor_animation.dispose
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # ○ カーソルアニメを表示
  115.   #--------------------------------------------------------------------------
  116.   def self.show_cursor_animation
  117.     @@__cursor_animation.visible = true
  118.     @@__cursor_animation.update
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ○ カーソルアニメを隠す
  122.   #--------------------------------------------------------------------------
  123.   def self.hide_cursor_animation
  124.     @@__cursor_animation.visible = false
  125.     @@__cursor_animation.update
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ○ カーソルアニメを更新
  129.   #--------------------------------------------------------------------------
  130.   def self.update_cursor_animation
  131.     @@__cursor_animation.update
  132.   end
  133. end

  134. #==============================================================================
  135. # ■ Game_System
  136. #==============================================================================

  137. class Game_System
  138.   #--------------------------------------------------------------------------
  139.   # ○ 公開インスタンス変数
  140.   #--------------------------------------------------------------------------
  141.   attr_writer :cursor_animation_visible
  142.   #--------------------------------------------------------------------------
  143.   # ○ オブジェクト初期化
  144.   #--------------------------------------------------------------------------
  145.   alias initialize_KMS_CursorAnimation initialize
  146.   def initialize
  147.     initialize_KMS_CursorAnimation

  148.     @cursor_animation_visible = KMS_CursorAnimation::DEFAULT_ANIMATION
  149.   end
  150.   #--------------------------------------------------------------------------
  151.   # ○ カーソルアニメ可否フラグを取得
  152.   #--------------------------------------------------------------------------
  153.   def cursor_animation_visible
  154.     if @cursor_animation_visible.nil?
  155.       @cursor_animation_visible = KMS_CursorAnimation::DEFAULT_ANIMATION
  156.     end
  157.     return @cursor_animation_visible
  158.   end
  159. end

  160. #==============================================================================
  161. # □ Sprite_CursorAnimation
  162. #------------------------------------------------------------------------------
  163. #  カーソルアニメーション用の処理を追加したスプライトのクラスです。
  164. #==============================================================================

  165. class Sprite_CursorAnimation < Sprite
  166.   #--------------------------------------------------------------------------
  167.   # ● オブジェクト初期化
  168.   #     viewport : ビューポート
  169.   #--------------------------------------------------------------------------
  170.   def initialize(viewport = nil)
  171.     super(viewport)
  172.     @duration    = 0
  173.     @frame_count = 0

  174.     self.bitmap = Cache.system(KMS_CursorAnimation::ANIMATION_FILE)
  175.     self.src_rect.width  = bitmap.width / 8
  176.     self.src_rect.height = bitmap.height /
  177.       ([KMS_CursorAnimation::FRAME_COUNT - 1, 0].max / 8 + 1)
  178.     self.ox         = src_rect.width  / 2
  179.     self.oy         = src_rect.height / 2
  180.     self.opacity    = KMS_CursorAnimation::OPACITY
  181.     self.blend_type = KMS_CursorAnimation::BLEND_TYPE
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● フレーム更新
  185.   #--------------------------------------------------------------------------
  186.   def update
  187.     super
  188.     return unless visible

  189.     @frame_count += 1
  190.     return if @frame_count % KMS_CursorAnimation::ANIMATION_WAIT != 0

  191.     @frame_count  = 0
  192.     @duration    -= 1
  193.     if @duration < 0
  194.       @duration = KMS_CursorAnimation::FRAME_COUNT - 1
  195.     end
  196.     update_animation
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ○ アニメーションを更新
  200.   #--------------------------------------------------------------------------
  201.   def update_animation
  202.     self.src_rect.x = src_rect.width  * (@duration % 8)
  203.     self.src_rect.y = src_rect.height * (@duration / 8)
  204.   end
  205. end

  206. #==============================================================================
  207. # □ Cursor_Animation
  208. #------------------------------------------------------------------------------
  209. #  カーソル周りのアニメーションを扱うクラスです。
  210. #==============================================================================

  211. class Cursor_Animation
  212.   #--------------------------------------------------------------------------
  213.   # ○ 公開インスタンス変数
  214.   #--------------------------------------------------------------------------
  215.   attr_accessor :visible
  216.   #--------------------------------------------------------------------------
  217.   # ○ オブジェクト初期化
  218.   #--------------------------------------------------------------------------
  219.   def initialize
  220.     reset
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # ○ 破棄
  224.   #--------------------------------------------------------------------------
  225.   def dispose
  226.     @target_sprite.dispose
  227.     @target_sprite = nil
  228.     @viewport.dispose
  229.     @viewport = nil
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ○ リセット
  233.   #--------------------------------------------------------------------------
  234.   def reset
  235.     @visible = false

  236.     @viewport      = Viewport.new(0, 0, 640, 480)
  237.     @windows       = []
  238.     @target_sprite = Sprite_CursorAnimation.new(@viewport)
  239.     @active_window = nil

  240.     @viewport.visible = false
  241.     @viewport.z = 30000
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ○ ウィンドウ追加
  245.   #--------------------------------------------------------------------------
  246.   def add_window(*window)
  247.     @windows |= window.find_all { |w|
  248.       w.is_a?(Window_Selectable) || w.is_a?(Window_SaveFile)
  249.     }
  250.     @windows.flatten!
  251.   end
  252.   #--------------------------------------------------------------------------
  253.   # ○ ウィンドウ削除
  254.   #--------------------------------------------------------------------------
  255.   def remove_window(*window)
  256.     @windows -= window
  257.   end
  258.   #--------------------------------------------------------------------------
  259.   # ○ フレーム更新
  260.   #--------------------------------------------------------------------------
  261.   def update
  262.     return if @viewport.nil?

  263.     @viewport.update
  264.     @target_sprite.update

  265.     # 座標調整
  266.     dest_x, dest_y = get_cursor_pos
  267.     if @target_sprite.x != dest_x
  268.       if (dest_x - @target_sprite.x).abs < 4
  269.         @target_sprite.x = dest_x
  270.       else
  271.         dist = (dest_x - @target_sprite.x) / 4
  272.         dist = (dist > 0 ? [dist, 4].max : [dist, -4].min)
  273.         @target_sprite.x += dist
  274.       end
  275.     end
  276.     if @target_sprite.y != dest_y
  277.       if (dest_y - @target_sprite.y).abs < 4
  278.         @target_sprite.y = dest_y
  279.       else
  280.         dist = (dest_y - @target_sprite.y) / 4
  281.         dist = (dist > 0 ? [dist, 4].max : [dist, -4].min)
  282.         @target_sprite.y += dist
  283.       end
  284.     end
  285.   end
  286.   #--------------------------------------------------------------------------
  287.   # ○ カーソル位置取得
  288.   #    [x, y] の形で返す。
  289.   #--------------------------------------------------------------------------
  290.   def get_cursor_pos
  291.     dx = dy = 0

  292.     # 可視状態のアクティブウィンドウを取得
  293.     unless window_active?(@active_window)
  294.       @active_window = search_active_window
  295.     end

  296.     # アクティブウィンドウがなければ非表示
  297.     if @active_window.nil? || !KMS_Commands.cursor_animation_visible?
  298.       @viewport.visible = false
  299.       dx = Graphics.width  / 2
  300.       dy = Graphics.height / 2
  301.       return [dx, dy]
  302.     end
  303.     @viewport.visible = @visible

  304.     # カーソル位置を計算
  305.     rect = @active_window.cursor_rect
  306.     dx   = rect.x + 16 + KMS_CursorAnimation::POSITION_REV[0]
  307.     dy   = rect.y + 16 + KMS_CursorAnimation::POSITION_REV[1]
  308.     vp   = @active_window.viewport
  309.     if vp != nil
  310.       dx += vp.rect.x - vp.ox
  311.       dy += vp.rect.y - vp.oy
  312.     end
  313.     dx += @active_window.x - @active_window.ox
  314.     dy += @active_window.y - @active_window.oy

  315.     case KMS_CursorAnimation::BASE_POSITION
  316.     when 0  # 上
  317.       dy += @target_sprite.oy
  318.     when 1  # 中央
  319.       dy += rect.height / 2
  320.     when 2  # 下
  321.       dy += rect.height - @target_sprite.oy
  322.     end
  323.     return [dx, dy]
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ○ ウィンドウの可視・アクティブ状態判定
  327.   #--------------------------------------------------------------------------
  328.   def window_active?(window)
  329.     return false if window.nil?
  330.     return false if window.disposed?
  331.     return false unless window.visible

  332.     if window.is_a?(Window_Selectable)
  333.       return window.active
  334.     elsif window.is_a?(Window_SaveFile)
  335.       return window.selected
  336.     end
  337.     return false
  338.   end
  339.   #--------------------------------------------------------------------------
  340.   # ○ アクティブウィンドウを探す
  341.   #--------------------------------------------------------------------------
  342.   def search_active_window
  343.     return @windows.find { |w|
  344.       if !w.visible
  345.         false
  346.       elsif w.is_a?(Window_Selectable)
  347.         w.active && w.index >= 0
  348.       elsif w.is_a?(Window_SaveFile)
  349.         w.selected
  350.       else
  351.         false
  352.       end
  353.     }
  354.   end
  355. end

  356. #==============================================================================
  357. # ■ Scene_Base
  358. #==============================================================================

  359. class Scene_Base
  360.   #--------------------------------------------------------------------------
  361.   # ● 開始処理
  362.   #--------------------------------------------------------------------------
  363.   alias start_KMS_CursorAnimation start
  364.   def start
  365.     Window_Base.create_cursor_animation
  366.     Window_Base.show_cursor_animation

  367.     start_KMS_CursorAnimation
  368.   end
  369.   #--------------------------------------------------------------------------
  370.   # ● 終了前処理
  371.   #--------------------------------------------------------------------------
  372.   alias pre_terminate_KMS_CursorAnimation pre_terminate
  373.   def pre_terminate
  374.     Window_Base.dispose_cursor_animation

  375.     pre_terminate_KMS_CursorAnimation
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # ● フレーム更新(基本)
  379.   #--------------------------------------------------------------------------
  380.   alias update_basic_KMS_CursorAnimation update_basic
  381.   def update_basic
  382.     update_basic_KMS_CursorAnimation

  383.     # カーソルアニメを更新
  384.     Window_Base.update_cursor_animation
  385.   end
  386. end
复制代码



跳过标题画面脚本:
  1. #===============================================================================
  2. # 作者:光的圆周率
  3. # 说明:脚本中注明的位置可以控制是否可以返回标题画面
  4. #       true:可以再次返回标题画面 false:不可以再次返回标题画面
  5. #===============================================================================

  6. module SceneManager

  7.   def self.stack
  8.      @stack
  9.   end
  10. end

  11. class Scene_Title < Scene_Base

  12.   alias old_start start
  13.   alias old_dmv dispose_main_viewport

  14.   def start

  15.       return_allowed = false      # 决定可否再次返回标题画面的开关
  16.       create_background
  17.       create_foreground
  18.       @sprite1.bitmap.dispose
  19.       @sprite2.bitmap.dispose
  20.       @foreground_sprite.bitmap.dispose
  21.       chk1 = SceneManager.stack.first != nil   && return_allowed
  22.       chk2 = Graphics.frame_count > 0  && return_allowed
  23.      if chk1 or chk2
  24.        old_start
  25.        return 0
  26.      end
  27.        SceneManager.clear
  28.        DataManager.setup_new_game
  29.        $game_map.autoplay
  30.        SceneManager.goto(Scene_Map)
  31.   end

  32.   def dispose_main_viewport
  33.     SceneManager.stack.first == nil ? nil : old_dmv
  34.   end
  35.   
  36. end
  37. #===============================================================================
  38. # 脚本来自66RPG,转载请保留版权信息
  39. #===============================================================================
复制代码
梦石
1
星屑
22113
在线时间
4886 小时
注册时间
2014-12-22
回帖
1509

开拓者

发表于 2016-5-4 19:48:16 | 显示全部楼层
本帖最后由 shencao 于 2016-5-4 20:13 编辑

我也用了跳过标题画面,光标动画我用的是+++ MOG - Menu Cursor (V1.9) +++这个没冲突来着

(我也用过顶楼的报错了我就换了个用,原来是和跳过标题画面冲了啊,我现在才知道,哈哈)

PS,
MOG - Menu Cursor (V1.9) 是来自
Atelier-Rgss
https://atelierrgss.wordpress.com/
我实在是不太确定能否直接转载(日本人就会写很详细,欧美一般都不写辣么细= =),贴个地址比较保险吧囧。
需要翻墙。需要的话随便找个在线代理翻一下吧~

点评

谢谢啦~哈哈哈  发表于 2016-5-5 12:51
发了。  发表于 2016-5-4 20:05
就是Atelier-Rgss的脚本,挺有名的,但是我现在也查不到是否允许转载(网站我都找不到了囧) 要不我给你发个私信吧,稍等啊。  发表于 2016-5-4 20:00
求~求~求,宇宙无敌洪荒之力超级————求脚本啊!!!  发表于 2016-5-4 19:53

评分

参与人数 1梦石 +1 收起 理由
丿梁丶小柒 + 1 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部