查看: 1627|回复: 1

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

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

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

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

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

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

光标的位置显示动画脚本:
[pre lang="ruby"]#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ カーソルアニメーション - KMS_CursorAnimation ◆ VX Ace ◆
#_/    ◇ Last update : 2012/02/19 (TOMY@Kamesoft) ◇
#_/----------------------------------------------------------------------------
#_/  光标的位置显示动画。
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ 設定項目 - BEGIN Setting ★
#==============================================================================

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

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

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

#==============================================================================
# ☆ 設定ここまで - END Setting ☆
#==============================================================================

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

# *****************************************************************************

#==============================================================================
# □ KMS_Commands
#==============================================================================

module KMS_Commands
  module_function
  #--------------------------------------------------------------------------
  # ○ カーソルアニメを表示
  #--------------------------------------------------------------------------
  def show_cursor_animation
    $game_system.cursor_animation_visible = true
  end
  #--------------------------------------------------------------------------
  # ○ カーソルアニメを非表示
  #--------------------------------------------------------------------------
  def hide_cursor_animation
    $game_system.cursor_animation_visible = false
  end
  #--------------------------------------------------------------------------
  # ○ カーソルアニメ表示状態の取得
  #--------------------------------------------------------------------------
  def cursor_animation_visible?
    return $game_system.cursor_animation_visible
  end
end

#==============================================================================
# ■ Game_Interpreter
#==============================================================================

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

#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ○ クラス変数
  #--------------------------------------------------------------------------
  @@__cursor_animation = nil  # カーソルアニメ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     x       : ウィンドウの X 座標
  #     y       : ウィンドウの Y 座標
  #     width   : ウィンドウの幅
  #     height  : ウィンドウの高さ
  #--------------------------------------------------------------------------
  alias initialize_KMS_CursorAnimation initialize
  def initialize(x, y, width, height)
    initialize_KMS_CursorAnimation(x, y, width, height)

    @@__cursor_animation.add_window(self)
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  unless method_defined?(:dispose_KMS_CursorAnimation)
    alias dispose_KMS_CursorAnimation dispose
  end
  def dispose
    @@__cursor_animation.remove_window(self)

    dispose_KMS_CursorAnimation
  end
  #--------------------------------------------------------------------------
  # ○ カーソルアニメを生成
  #--------------------------------------------------------------------------
  def self.create_cursor_animation
    @@__cursor_animation = Cursor_Animation.new
  end
  #--------------------------------------------------------------------------
  # ○ カーソルアニメを破棄
  #--------------------------------------------------------------------------
  def self.dispose_cursor_animation
    @@__cursor_animation.dispose
  end
  #--------------------------------------------------------------------------
  # ○ カーソルアニメを表示
  #--------------------------------------------------------------------------
  def self.show_cursor_animation
    @@__cursor_animation.visible = true
    @@__cursor_animation.update
  end
  #--------------------------------------------------------------------------
  # ○ カーソルアニメを隠す
  #--------------------------------------------------------------------------
  def self.hide_cursor_animation
    @@__cursor_animation.visible = false
    @@__cursor_animation.update
  end
  #--------------------------------------------------------------------------
  # ○ カーソルアニメを更新
  #--------------------------------------------------------------------------
  def self.update_cursor_animation
    @@__cursor_animation.update
  end
end

#==============================================================================
# ■ Game_System
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_writer :cursor_animation_visible
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_KMS_CursorAnimation initialize
  def initialize
    initialize_KMS_CursorAnimation

    @cursor_animation_visible = KMS_CursorAnimation::DEFAULT_ANIMATION
  end
  #--------------------------------------------------------------------------
  # ○ カーソルアニメ可否フラグを取得
  #--------------------------------------------------------------------------
  def cursor_animation_visible
    if @cursor_animation_visible.nil?
      @cursor_animation_visible = KMS_CursorAnimation::DEFAULT_ANIMATION
    end
    return @cursor_animation_visible
  end
end

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

class Sprite_CursorAnimation < Sprite
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #     viewport : ビューポート
  #--------------------------------------------------------------------------
  def initialize(viewport = nil)
    super(viewport)
    @duration    = 0
    @frame_count = 0

    self.bitmap = Cache.system(KMS_CursorAnimation::ANIMATION_FILE)
    self.src_rect.width  = bitmap.width / 8
    self.src_rect.height = bitmap.height /
      ([KMS_CursorAnimation::FRAME_COUNT - 1, 0].max / 8 + 1)
    self.ox         = src_rect.width  / 2
    self.oy         = src_rect.height / 2
    self.opacity    = KMS_CursorAnimation::OPACITY
    self.blend_type = KMS_CursorAnimation::BLEND_TYPE
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    return unless visible

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

    @frame_count  = 0
    @duration    -= 1
    if @duration < 0
      @duration = KMS_CursorAnimation::FRAME_COUNT - 1
    end
    update_animation
  end
  #--------------------------------------------------------------------------
  # ○ アニメーションを更新
  #--------------------------------------------------------------------------
  def update_animation
    self.src_rect.x = src_rect.width  * (@duration % 8)
    self.src_rect.y = src_rect.height * (@duration / 8)
  end
end

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

class Cursor_Animation
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :visible
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    reset
  end
  #--------------------------------------------------------------------------
  # ○ 破棄
  #--------------------------------------------------------------------------
  def dispose
    @target_sprite.dispose
    @target_sprite = nil
    @viewport.dispose
    @viewport = nil
  end
  #--------------------------------------------------------------------------
  # ○ リセット
  #--------------------------------------------------------------------------
  def reset
    @visible = false

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

    @viewport.visible = false
    @viewport.z = 30000
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ追加
  #--------------------------------------------------------------------------
  def add_window(*window)
    @windows |= window.find_all { |w|
      w.is_a?(Window_Selectable) || w.is_a?(Window_SaveFile)
    }
    @windows.flatten!
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ削除
  #--------------------------------------------------------------------------
  def remove_window(*window)
    @windows -= window
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    return if @viewport.nil?

    @viewport.update
    @target_sprite.update

    # 座標調整
    dest_x, dest_y = get_cursor_pos
    if @target_sprite.x != dest_x
      if (dest_x - @target_sprite.x).abs < 4
        @target_sprite.x = dest_x
      else
        dist = (dest_x - @target_sprite.x) / 4
        dist = (dist > 0 ? [dist, 4].max : [dist, -4].min)
        @target_sprite.x += dist
      end
    end
    if @target_sprite.y != dest_y
      if (dest_y - @target_sprite.y).abs < 4
        @target_sprite.y = dest_y
      else
        dist = (dest_y - @target_sprite.y) / 4
        dist = (dist > 0 ? [dist, 4].max : [dist, -4].min)
        @target_sprite.y += dist
      end
    end
  end
  #--------------------------------------------------------------------------
  # ○ カーソル位置取得
  #    [x, y] の形で返す。
  #--------------------------------------------------------------------------
  def get_cursor_pos
    dx = dy = 0

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

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

    # カーソル位置を計算
    rect = @active_window.cursor_rect
    dx   = rect.x + 16 + KMS_CursorAnimation::POSITION_REV[0]
    dy   = rect.y + 16 + KMS_CursorAnimation::POSITION_REV[1]
    vp   = @active_window.viewport
    if vp != nil
      dx += vp.rect.x - vp.ox
      dy += vp.rect.y - vp.oy
    end
    dx += @active_window.x - @active_window.ox
    dy += @active_window.y - @active_window.oy

    case KMS_CursorAnimation::BASE_POSITION
    when 0  # 上
      dy += @target_sprite.oy
    when 1  # 中央
      dy += rect.height / 2
    when 2  # 下
      dy += rect.height - @target_sprite.oy
    end
    return [dx, dy]
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウの可視・アクティブ状態判定
  #--------------------------------------------------------------------------
  def window_active?(window)
    return false if window.nil?
    return false if window.disposed?
    return false unless window.visible

    if window.is_a?(Window_Selectable)
      return window.active
    elsif window.is_a?(Window_SaveFile)
      return window.selected
    end
    return false
  end
  #--------------------------------------------------------------------------
  # ○ アクティブウィンドウを探す
  #--------------------------------------------------------------------------
  def search_active_window
    return @windows.find { |w|
      if !w.visible
        false
      elsif w.is_a?(Window_Selectable)
        w.active && w.index >= 0
      elsif w.is_a?(Window_SaveFile)
        w.selected
      else
        false
      end
    }
  end
end

#==============================================================================
# ■ Scene_Base
#==============================================================================

class Scene_Base
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  alias start_KMS_CursorAnimation start
  def start
    Window_Base.create_cursor_animation
    Window_Base.show_cursor_animation

    start_KMS_CursorAnimation
  end
  #--------------------------------------------------------------------------
  # ● 終了前処理
  #--------------------------------------------------------------------------
  alias pre_terminate_KMS_CursorAnimation pre_terminate
  def pre_terminate
    Window_Base.dispose_cursor_animation

    pre_terminate_KMS_CursorAnimation
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新(基本)
  #--------------------------------------------------------------------------
  alias update_basic_KMS_CursorAnimation update_basic
  def update_basic
    update_basic_KMS_CursorAnimation

    # カーソルアニメを更新
    Window_Base.update_cursor_animation
  end
end
[/pre]


跳过标题画面脚本:
[pre lang="ruby"]#===============================================================================
# 作者:光的圆周率
# 说明:脚本中注明的位置可以控制是否可以返回标题画面
#       true:可以再次返回标题画面 false:不可以再次返回标题画面
#===============================================================================

module SceneManager

  def self.stack
     @stack
  end
end

class Scene_Title < Scene_Base

  alias old_start start
  alias old_dmv dispose_main_viewport

  def start

      return_allowed = false      # 决定可否再次返回标题画面的开关
      create_background
      create_foreground
      @sprite1.bitmap.dispose
      @sprite2.bitmap.dispose
      @foreground_sprite.bitmap.dispose
      chk1 = SceneManager.stack.first != nil   && return_allowed
      chk2 = Graphics.frame_count > 0  && return_allowed
     if chk1 or chk2
       old_start
       return 0
     end
       SceneManager.clear
       DataManager.setup_new_game
       $game_map.autoplay
       SceneManager.goto(Scene_Map)
  end

  def dispose_main_viewport
    SceneManager.stack.first == nil ? nil : old_dmv
  end
  
end
#===============================================================================
# 脚本来自66RPG,转载请保留版权信息
#===============================================================================[/pre]
梦石
1
星屑
22083
在线时间
4885 小时
注册时间
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.

在本版发帖返回顶部