| 
 
| 赞 | 6 |  
| VIP | 1 |  
| 好人卡 | 0 |  
| 积分 | 2 |  
| 经验 | 12152 |  
| 最后登录 | 2024-3-31 |  
| 在线时间 | 149 小时 |  
 Lv1.梦旅人 
	梦石0 星屑155 在线时间149 小时注册时间2015-10-14帖子212 | 
3楼
 
 
 楼主|
发表于 2016-11-1 21:23:41
|
只看该作者 
| 复制代码#encoding:utf-8
=begin
*******************************************************************************************
   * 立繪系統 *
                       for RGSS3
        Ver 1.2   2016.08.29
   原作者:魂(Lctseng),巴哈姆特論壇ID:play123
   轉載請保留此標籤
   個人小屋連結:http://home.gamer.com.tw/homeindex.php?owner=play123
   需求前置腳本:Lctseng - 圖像精靈強化
   請將此腳本至於該腳本底下
   主要功能:
                       一、顯示左右邊的立繪,與對話框分開(即沒有關聯)
   更新紀錄:
    Ver 1.00 :
    日期:2014.09.24
    摘要:■、最初版本
    Ver 1.10 :
    日期:2014.10.30
    摘要:■、加入調整透明度的功能
    Ver 1.11 :
    日期:2014.11.05
    摘要:■、修正立即出現沒有調整透明度的錯誤
    Ver 1.2 :
    日期:2016.08.29
    摘要:■、移除對話框行數多一行的部分
    撰寫摘要:一、此腳本修改或重新定義以下類別:
                           ■ Game_Interpreter
                           ■ Game_System
                           ■ Scene_Base
                           ■ Scene_Map
                        二、此腳本新定義以下類別和模組:
                           ■ Lctseng::Game_StandController
                           ■ Lctseng::Game_Stand
                           ■ Lctseng::Game_LeftStand
                           ■ Lctseng::Game_RightStand
                           ■ Lctseng::Spriteset_Stand
                           ■ Lctseng::Sprite_Stand
                           ■ Lctseng::Sprite_LeftStand
                           ■ Lctseng::Sprite_RightStand
*******************************************************************************************
=end
#*******************************************************************************************
#
#   請勿修改從這裡以下的程式碼,除非你知道你在做什麼!
#   DO NOT MODIFY UNLESS YOU KNOW WHAT TO DO !
#
#*******************************************************************************************
#--------------------------------------------------------------------------
# ★ 紀錄腳本資訊
#--------------------------------------------------------------------------
if !$lctseng_scripts
  $lctseng_scripts = {}
end
## 檢查前置腳本
if !$lctseng_scripts[:sprite_ex]
  msgbox("沒有發現前置腳本:Lctseng - 圖像精靈強化\n或者是腳本位置錯誤!\n程式即將關閉")
  exit
end
$lctseng_scripts[:stand_picture] = "1.11"
puts "載入腳本:Lctseng - 立繪系統,版本:#{$lctseng_scripts[:stand_picture]}"
#encoding:utf-8
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  事件指令的解釋器。
#   本類在 Game_Map、Game_Troop、Game_Event 類的內部使用。
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● 左圖片飛入
  #--------------------------------------------------------------------------
  def left_slide_in(*args)
    $game_system.stand.left_slide_in(*args)
  end
  #--------------------------------------------------------------------------
  # ● 左圖片飛出
  #--------------------------------------------------------------------------
  def left_slide_out(*args)
    $game_system.stand.left_slide_out(*args)
  end
  #--------------------------------------------------------------------------
  # ● 左圖片更換
  #--------------------------------------------------------------------------
  def left_change(*args)
    $game_system.stand.left_change(*args)
  end
  #--------------------------------------------------------------------------
  # ● 右圖片飛入
  #--------------------------------------------------------------------------
  def right_slide_in(*args)
    $game_system.stand.right_slide_in(*args)
  end
  #--------------------------------------------------------------------------
  # ● 右圖片飛出
  #--------------------------------------------------------------------------
  def right_slide_out(*args)
    $game_system.stand.right_slide_out(*args)
  end
  #--------------------------------------------------------------------------
  # ● 右圖片更換
  #--------------------------------------------------------------------------
  def right_change(*args)
    $game_system.stand.right_change(*args)
  end
  #--------------------------------------------------------------------------
  # ● 左圖片Z座標更換
  #--------------------------------------------------------------------------
  def left_z(val)
    $game_system.stand.left.z = val
  end
  #--------------------------------------------------------------------------
  # ● 右圖片Z座標更換
  #--------------------------------------------------------------------------
  def right_z(val)
    $game_system.stand.right.z = val
  end
  #--------------------------------------------------------------------------
  # ● 左圖片在對話框前
  #--------------------------------------------------------------------------
  def left_front
    left_z(500)
  end
  #--------------------------------------------------------------------------
  # ● 左圖片在對話框後
  #--------------------------------------------------------------------------
  def left_behind
    left_z(50)
  end
  #--------------------------------------------------------------------------
  # ● 右圖片在對話框前
  #-------------------------------------------------------------------------
  def right_front
    right_z(500)
  end
  #--------------------------------------------------------------------------
  # ● 右圖片在對話框後
  #--------------------------------------------------------------------------
  def right_behind
    right_z(50)
  end
  #--------------------------------------------------------------------------
  # ● 左圖片最大透明限制
  #--------------------------------------------------------------------------
  def left_limit_opacity(*args)
    $game_system.stand.left_limit_opacity(*args)
  end
  #--------------------------------------------------------------------------
  # ● 右圖片最大透明限制
  #--------------------------------------------------------------------------
  def right_limit_opacity(*args)
    $game_system.stand.right_limit_opacity(*args)
  end
end
#encoding:utf-8
#==============================================================================
# ■ Game_System
#------------------------------------------------------------------------------
#  處理系統附屬數據的類。保存存檔和菜單的禁止狀態之類的數據。
#   本類的實例請參考 $game_system 。
#==============================================================================
class Game_System
  #--------------------------------------------------------------------------
  # ● 取得立繪控制物件
  #--------------------------------------------------------------------------
  def stand
    [url=home.php?mod=space&uid=33296]@stand[/url] ||= Lctseng::Game_StandController.new
  end
end
#encoding:utf-8
#==============================================================================
# ■ Lctseng::Game_StandController
#------------------------------------------------------------------------------
#  控制立繪物件
#==============================================================================
module Lctseng
class Game_StandController
  #--------------------------------------------------------------------------
  # ● 定義實例變數
  #--------------------------------------------------------------------------
  attr_reader :left
  attr_reader :right
  #--------------------------------------------------------------------------
  # ● 初始化對象
  #--------------------------------------------------------------------------
  def initialize
    [url=home.php?mod=space&uid=456159]@left[/url] = Game_LeftStand.new
    @right = Game_RightStand.new
  end
  #--------------------------------------------------------------------------
  # ● 當精靈組被釋放的時候的處理
  #--------------------------------------------------------------------------
  def on_terminate
    # 全部飛出
    left_slide_out
    right_slide_out
  end
  #--------------------------------------------------------------------------
  # ● 左圖片飛入
  #--------------------------------------------------------------------------
  def left_slide_in(filename)
    @left.change_filename(filename)
    @left.slide_in_req
  end
  #--------------------------------------------------------------------------
  # ● 左圖片飛出
  #--------------------------------------------------------------------------
  def left_slide_out
    @left.slide_out_req
  end
  #--------------------------------------------------------------------------
  # ● 左圖片最大透明限制
  #--------------------------------------------------------------------------
  def left_limit_opacity(value)
    @left.limit_opacity(value)
  end
  #--------------------------------------------------------------------------
  # ● 右圖片飛入
  #--------------------------------------------------------------------------
  def right_slide_in(filename)
    @right.change_filename(filename)
    @right.slide_in_req
  end
  #--------------------------------------------------------------------------
  # ● 右圖片飛出
  #--------------------------------------------------------------------------
  def right_slide_out
    @right.slide_out_req
  end
  #--------------------------------------------------------------------------
  # ● 右圖片最大透明限制
  #--------------------------------------------------------------------------
  def right_limit_opacity(value)
    @right.limit_opacity(value)
  end
  #--------------------------------------------------------------------------
  # ● 左圖片更換
  #--------------------------------------------------------------------------
  def left_change(filename,fast = false)
    @left.change(filename,fast)
  end
  #--------------------------------------------------------------------------
  # ● 右圖片更換
  #--------------------------------------------------------------------------
  def right_change(filename,fast = false)
    @right.change(filename,fast)
  end
end
end
#encoding:utf-8
#==============================================================================
# ■ Lctseng::Game_Stand
#------------------------------------------------------------------------------
#  立繪物件
#==============================================================================
module Lctseng
class Game_Stand
  #--------------------------------------------------------------------------
  # ● 定義實例變數
  #--------------------------------------------------------------------------
  attr_reader :status
  attr_reader :filename
  attr_reader :new_filename
  attr_reader :old_filename
  attr_reader :change_fast
  attr_reader :opacity_limit
  attr_accessor :z
  #--------------------------------------------------------------------------
  # ● 初始化對象
  #--------------------------------------------------------------------------
  def initialize
    # 檔名
    @filename = ''
    # 狀態:
    # :none 無
    # :slide_in_req 要求飛入
    # :sliding_in   飛入中
    # slide_out_req  要求飛出
    # :sliding_out  飛出中
    # :show 顯示中
    # :change_req 要求更換
    # :changing 更換中
    @status = :none
    # 更換時的新檔名【僅show中更換時生效】
    @new_filename = ''
    # 更換時的舊檔名【僅show中更換時生效】
    @old_filename = ''
    # 更換時是否快速更換,代表立即顯示不淡入
    @change_fast = false
    #  Z 座標
    @z = 300
    # 透明度最大限制
    @opacity_limit = 255
  end
  #--------------------------------------------------------------------------
  # ● 回應飛入要求
  #--------------------------------------------------------------------------
  def response_slide_in
    @status = :sliding_in
  end
  #--------------------------------------------------------------------------
  # ● 回應飛入結束
  #--------------------------------------------------------------------------
  def response_slide_in_end
    @status = :show
  end
  #--------------------------------------------------------------------------
  # ● 回應飛出要求
  #--------------------------------------------------------------------------
  def response_slide_out
    @status = :sliding_out
  end
  #--------------------------------------------------------------------------
  # ● 回應飛出結束
  #--------------------------------------------------------------------------
  def response_slide_out_end
    @status = :none
  end
  #--------------------------------------------------------------------------
  # ● 回應更換要求
  #--------------------------------------------------------------------------
  def response_change_req
    @status = :changing
  end
  #--------------------------------------------------------------------------
  # ● 回應更換結束
  #--------------------------------------------------------------------------
  def response_change_end
    @status = :show
  end
  #--------------------------------------------------------------------------
  # ● 檔名更換
  #--------------------------------------------------------------------------
  def change_filename(new_name)
    @old_filename = @filename
    @new_filename = @filename = new_name
  end
  #--------------------------------------------------------------------------
  # ● 切換
  #--------------------------------------------------------------------------
  def change(new_name,fast)
    @change_fast = fast
    change_filename(new_name)
    @status = :change_req
  end
  #--------------------------------------------------------------------------
  # ● 要求飛入
  #--------------------------------------------------------------------------
  def slide_in_req
    @status = :slide_in_req
  end
  #--------------------------------------------------------------------------
  # ● 要求飛出
  #--------------------------------------------------------------------------
  def slide_out_req
    @status = :slide_out_req if @status != :none
  end
  #--------------------------------------------------------------------------
  # ● 限制透明度
  #--------------------------------------------------------------------------
  def limit_opacity(value)
    @opacity_limit = value
  end
end
end
#encoding:utf-8
#==============================================================================
# ■ Lctseng::Game_LeftStand
#------------------------------------------------------------------------------
#  左方立繪物件
#==============================================================================
module Lctseng
class Game_LeftStand < Game_Stand
  #--------------------------------------------------------------------------
  # ● 初始化對象
  #--------------------------------------------------------------------------
  def initialize
    super
  end
end
end
#encoding:utf-8
#==============================================================================
# ■ Lctseng::Game_RightStand
#------------------------------------------------------------------------------
#  右方立繪物件
#==============================================================================
module Lctseng
class Game_RightStand < Game_Stand
  #--------------------------------------------------------------------------
  # ● 初始化對象
  #--------------------------------------------------------------------------
  def initialize
    super
  end
end
end
#encoding:utf-8
#==============================================================================
# ■ Lctseng::Spriteset_Stand
#------------------------------------------------------------------------------
#     處理立繪的精靈組
#     監視Game_StandController進行立繪處理
#==============================================================================
module Lctseng
class Spriteset_Stand
  #--------------------------------------------------------------------------
  # ● 加入設定模組
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # ● 初始化對象
  #--------------------------------------------------------------------------
  def initialize(viewport)
    @viewport = viewport
    @terminating_count = 0
    create_sprites
  end
  #--------------------------------------------------------------------------
  # ● 取得控制器
  #--------------------------------------------------------------------------
  def control
    $game_system.stand
  end
  #--------------------------------------------------------------------------
  # ● 產生精靈
  #--------------------------------------------------------------------------
  def create_sprites
    @left = Lctseng::Sprite_LeftStand.new(@viewport)
    @right = Lctseng::Sprite_RightStand.new(@viewport)
  end
  #--------------------------------------------------------------------------
  # ● 釋放
  #--------------------------------------------------------------------------
  def dispose
    dispose_sprites
  end
  #--------------------------------------------------------------------------
  # ● 釋放精靈
  #--------------------------------------------------------------------------
  def dispose_sprites
    @left.dispose
    @right.dispose
  end
  #--------------------------------------------------------------------------
  # ● 釋放
  #--------------------------------------------------------------------------
  def any_sprite_show?
    return true if @left&&@left.control.status != :none
    return true if @right&&@right.control.status != :none
    return false
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  def update
    update_sprites
  end
  #--------------------------------------------------------------------------
  # ● 更新精靈
  #--------------------------------------------------------------------------
  def update_sprites
    @left.update
    @right.update
  end
  #--------------------------------------------------------------------------
  # ● 結束計數
  #--------------------------------------------------------------------------
  def terminate_countdown
    @terminating_count -= 1
  end
  #--------------------------------------------------------------------------
  # ● 結束中?
  #--------------------------------------------------------------------------
  def terminating?
    @terminating_count > 0
  end
  #--------------------------------------------------------------------------
  # ● 終止
  #--------------------------------------------------------------------------
  def terminate
    puts "終止處理"
    control.on_terminate
    if any_sprite_show?
      puts "要求終止前顯示"
      @terminating_count  = 35
    end
  end
end
end
#encoding:utf-8
#==============================================================================
# ■ Lctseng::Sprite_Stand
#------------------------------------------------------------------------------
#     立繪精靈
#==============================================================================
module Lctseng
class Sprite_Stand < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 加入淡入淡出與移動模組
  #--------------------------------------------------------------------------
  include SpriteFader
  include SpriteSlider
  #--------------------------------------------------------------------------
  # ● 初始化對象
  #--------------------------------------------------------------------------
  def initialize(viewport)
    @opacity_limit = 255
    @origin_opacity = 255
    super(viewport)
    @origin_opacity = self.opacity
    @filename = ''
    check_opacity
    fader_init
    slider_init
    [url=home.php?mod=space&uid=31758]@Shadow[/url] = Sprite_StandShadow.new(self,viewport)
  end
  #--------------------------------------------------------------------------
  # ● 取得控制物件
  #--------------------------------------------------------------------------
  def control
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  def update
    super
    check_opacity
    check_action
    fader_update
    slider_update
    self.z = control.z
    @shadow.update
  end
  #--------------------------------------------------------------------------
  # ● 設定透明度
  #--------------------------------------------------------------------------
  alias :set_opacity :opacity=
  #--------------------------------------------------------------------------
  def opacity=(val)
    @origin_opacity = val
    adj = [@origin_opacity,@opacity_limit].min
    set_opacity(adj)
  end
  #--------------------------------------------------------------------------
  # ● 檢查透明度
  #--------------------------------------------------------------------------
  def check_opacity
    if  @opacity_limit != control.opacity_limit
      @opacity_limit = control.opacity_limit
      self.opacity = @origin_opacity
    end
  end
  #--------------------------------------------------------------------------
  # ● 檢查動作
  #--------------------------------------------------------------------------
  def check_action
    #puts "狀態:#{control.status}"
    case control.status
    when :none
      hide
    when :slide_in_req
      check_filename
      reset_position
      slide_in
      control.response_slide_in
    when :sliding_in
      if !slider_sliding?
        control.response_slide_in_end
      end
    when :slide_out_req
      slide_out
      control.response_slide_out
    when :sliding_out
      if !slider_sliding?
        control.response_slide_out_end
      end
    when :change_req
      if control.change_fast
        change_immediately
        control.response_change_end
      else
        setup_shadow
        control.response_change_req
      end
    when :changing
      if !fader_fading? && [email protected]_fading?
        control.response_change_end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 隱藏
  #--------------------------------------------------------------------------
  def hide
    self.opacity = 0
  end
  #--------------------------------------------------------------------------
  # ● 檢查檔名
  #--------------------------------------------------------------------------
  def check_filename
    # 若檔案更換,則重新建立位圖
    if @filename != control.filename
      change_immediately
    end
  end
  #--------------------------------------------------------------------------
  # ● 重置位置
  #--------------------------------------------------------------------------
  def reset_position
    return unless self.bitmap
    set_pos(slided_out_pos)
  end
  #--------------------------------------------------------------------------
  # ● 取得已飛入的位置
  #--------------------------------------------------------------------------
  def slided_in_pos
    [0,Graphics.height - self.height]
  end
  #--------------------------------------------------------------------------
  # ● 取得已飛出的位置
  #--------------------------------------------------------------------------
  def slided_out_pos
    [-0.5 * self.width,Graphics.height - self.height]
  end
  #--------------------------------------------------------------------------
  # ● 釋放
  #--------------------------------------------------------------------------
  def dispose
    super
    @shadow.dispose
  end
  #--------------------------------------------------------------------------
  # ● 飛入顯示
  #--------------------------------------------------------------------------
  def slide_in
    fader_set_fade(255,30)
    slider_set_move(current_pos,slided_in_pos,30)
  end
  #--------------------------------------------------------------------------
  # ● 飛出隱藏
  #--------------------------------------------------------------------------
  def slide_out
    fader_set_fade(0,30)
    slider_set_move(current_pos,slided_out_pos,30)
  end
  #--------------------------------------------------------------------------
  # ● 立即更換
  #--------------------------------------------------------------------------
  def change_immediately
    @filename = control.filename
    self.bitmap = Cache.picture(@filename)
    # 重新對齊座標
    set_pos(slide_in_pos_adjust(slided_in_pos))
    # 設定透明度
    self.opacity = 255
  end
  #--------------------------------------------------------------------------
  # ● 設置陰影
  # 將舊圖片作為殘影,主精靈使用新圖片淡入
  #--------------------------------------------------------------------------
  def setup_shadow
    @shadow.setup
    change_immediately
    self.opacity = 0
    fader_set_fade(255,30)
  end
  #--------------------------------------------------------------------------
  # ● 已飛入位置調整
  #--------------------------------------------------------------------------
  def slide_in_pos_adjust(pos)
    pos
  end
end
end
#encoding:utf-8
#==============================================================================
# ■ Lctseng::Sprite_StandShadow
#------------------------------------------------------------------------------
#     立繪陰影精靈,主精靈更換圖片時,用來淡出舊圖片
#==============================================================================
module Lctseng
class Sprite_StandShadow < Sprite_Base
  #--------------------------------------------------------------------------
  # ● 加入淡入淡出與移動模組
  #--------------------------------------------------------------------------
  include SpriteFader
  #--------------------------------------------------------------------------
  # ● 初始化對象
  #--------------------------------------------------------------------------
  def initialize(main,viewport)
    super(viewport)
    [url=home.php?mod=space&uid=217648]@Main[/url] = main
    fader_init
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  def update
    super
    fader_update
  end
  #--------------------------------------------------------------------------
  # ● 設置
  #--------------------------------------------------------------------------
  def setup
    self.bitmap = Cache.picture(@main.control.old_filename)
    self.opacity = @main.opacity
    self.x = @main.x
    self.y = @main.y
    fader_set_fade(0,30)
  end
end
end
#encoding:utf-8
#==============================================================================
# ■ Lctseng::Sprite_LeftStand
#------------------------------------------------------------------------------
#     左方立繪精靈
#==============================================================================
module Lctseng
class Sprite_LeftStand < Sprite_Stand
  #--------------------------------------------------------------------------
  # ● 取得控制物件
  #--------------------------------------------------------------------------
  def control
    $game_system.stand.left
  end
  #--------------------------------------------------------------------------
  # ● 重置位置
  #--------------------------------------------------------------------------
  def reset_position
    return unless self.bitmap
    super
    self.x = self.width * -0.5
  end
  #--------------------------------------------------------------------------
  # ● 取得已飛入的位置
  #--------------------------------------------------------------------------
  def slided_in_pos
    pos = super
    pos[0] = 0 # x座標為0
    slide_in_pos_adjust(pos)
  end
  #--------------------------------------------------------------------------
  # ● 已飛入位置調整
  #--------------------------------------------------------------------------
  def slide_in_pos_adjust(pos)
    # 限制不過半
    if pos[0] + self.width > 320
      pos[0] = 320 - self.width
    end
    pos
  end
  #--------------------------------------------------------------------------
  # ● 取得已飛出的位置
  #--------------------------------------------------------------------------
  def slided_out_pos
    pos = super
    pos[0] = -0.5 * self.width # x座標為負的一半寬度
    pos
  end
end
end
#encoding:utf-8
#==============================================================================
# ■ Lctseng::Sprite_RightStand
#------------------------------------------------------------------------------
#     右方立繪精靈
#==============================================================================
module Lctseng
class Sprite_RightStand < Sprite_Stand
  #--------------------------------------------------------------------------
  # ● 取得控制物件
  #--------------------------------------------------------------------------
  def control
    $game_system.stand.right
  end
  #--------------------------------------------------------------------------
  # ● 重置位置
  #--------------------------------------------------------------------------
  def reset_position
    return unless self.bitmap
    super
    self.x = Graphics.width - self.width * 0.5
  end
  #--------------------------------------------------------------------------
  # ● 取得已飛入的位置
  #--------------------------------------------------------------------------
  def slided_in_pos
    pos = super
    pos[0] = Graphics.width - self.width
    slide_in_pos_adjust(pos)
  end
  #--------------------------------------------------------------------------
  # ● 已飛入位置調整
  #--------------------------------------------------------------------------
  def slide_in_pos_adjust(pos)
    # 限制不過半
    if pos[0] < 320
      pos[0] = 320
    end
    pos
  end
  #--------------------------------------------------------------------------
  # ● 取得已飛出的位置
  #--------------------------------------------------------------------------
  def slided_out_pos
    pos = super
    pos[0] = Graphics.width - self.width * 0.5
    pos
  end
end
end
#encoding:utf-8
#==============================================================================
# ■ Scene_Base
#------------------------------------------------------------------------------
#  游戲中所有 Scene 類(場景類)的父類
#==============================================================================
class Scene_Base
  #--------------------------------------------------------------------------
  # ● 重新定義
  #--------------------------------------------------------------------------
  unless $@
    alias lctseng_stand_start start
    alias lctseng_stand_update_basic update_basic
    alias lctseng_stand_terminate terminate
  end
  #--------------------------------------------------------------------------
  # ● 開始處理 【重新定義】
  #--------------------------------------------------------------------------
  def start
    lctseng_stand_start
    #create_stand_viewport
    create_stand_spriteset
  end
  #--------------------------------------------------------------------------
  # ● 產生立繪顯示端口
  #--------------------------------------------------------------------------
  def create_stand_viewport
    @viewport_stand = Viewport.new
    @viewport_stand.z = 100
  end
  #--------------------------------------------------------------------------
  # ● 產生立繪精靈
  #--------------------------------------------------------------------------
  def create_stand_spriteset
    # 修改不使用顯示端口,以便控制Z座標
    @stand_spriteset = Lctseng::Spriteset_Stand.new(nil)
  end
  #--------------------------------------------------------------------------
  # ● 更新畫面(基礎)【重新定義】
  #--------------------------------------------------------------------------
  def update_basic
    lctseng_stand_update_basic
    update_stand_spriteset
  end
  #--------------------------------------------------------------------------
  # ● 更新立繪精靈
  #--------------------------------------------------------------------------
  def update_stand_spriteset
    @stand_spriteset.update
  end
  #--------------------------------------------------------------------------
  # ● 結束處理【重新定義】
  #--------------------------------------------------------------------------
  def terminate
    stand_terminate
    lctseng_stand_terminate
    dispose_stand_spriteset
    #dispose_stand_viewport
  end
  #--------------------------------------------------------------------------
  # ● 釋放立繪精靈
  #--------------------------------------------------------------------------
  def dispose_stand_spriteset
    @stand_spriteset.dispose
  end
  #--------------------------------------------------------------------------
  # ● 釋放立繪顯示端口
  #--------------------------------------------------------------------------
  def dispose_stand_viewport
    @viewport_stand.dispose
  end
  #--------------------------------------------------------------------------
  # ● 立繪結束處理
  #--------------------------------------------------------------------------
  def stand_terminate
    @stand_spriteset.terminate
    while @stand_spriteset.terminating?
      @stand_spriteset.terminate_countdown
      puts "結束前處理"
      @stand_spriteset.update
      Graphics.update
    end
  end
end
#encoding:utf-8
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  地圖畫面
#==============================================================================
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # ● 重新定義
  #--------------------------------------------------------------------------
  unless $@
    alias lctseng_stand_pre_transfer pre_transfer
  end
  #--------------------------------------------------------------------------
  # ● 場所移動前的處理【重新定義】
  #--------------------------------------------------------------------------
  def pre_transfer
    puts "場所移動處理"
    stand_terminate
    lctseng_stand_pre_transfer
  end
end
 需要配合使用的图像精灵强化脚本(前置脚本)
 
 复制代码#encoding:utf-8
=begin
*******************************************************************************************
   * 圖像精靈強化 *
                       for RGSS3
        Ver 1.10   2014.12.02
   原作者:魂(Lctseng),巴哈姆特論壇ID:play123
   
   轉載請保留此標籤
   個人小屋連結:http://home.gamer.com.tw/homeindex.php?owner=play123
   主要功能:
                       一、大部分Lctseng發布的圖像有關腳本都需要有此腳本作為前置腳本
                       
   更新紀錄:
    Ver 1.00 :
    日期:2014.09.24
    摘要:■、最初版本
    Ver 1.10 :
    日期:2014.12.02
    摘要:■、更新Sprite_Drawer,新增param_change_color
    
    撰寫摘要:一、此腳本修改或重新定義以下類別:
                           ■ Sprite
                          
                        二、此腳本新定義以下類別和模組:
                           ■ SpriteDrawer
                           ■ SpriteFader
                           ■ SpriteSlider
                           ■ SpriteSensor
                           ■ SpriteZoomer
                          
*******************************************************************************************
=end
#*******************************************************************************************
#
#   請勿修改從這裡以下的程式碼,除非你知道你在做什麼!
#   DO NOT MODIFY UNLESS YOU KNOW WHAT TO DO ! 
#
#*******************************************************************************************
#--------------------------------------------------------------------------
# ★ 紀錄腳本資訊
#--------------------------------------------------------------------------
if !$lctseng_scripts  
  $lctseng_scripts = {}
end
$lctseng_scripts[:sprite_ex] = "1.00"
puts "載入腳本:Lctseng - 圖像精靈強化,版本:#{$lctseng_scripts[:sprite_ex]}"
#encoding:utf-8
#==============================================================================
# ■ Sprite
#------------------------------------------------------------------------------
#  精靈。
#==============================================================================
class  Sprite
  #--------------------------------------------------------------------------
  # ● 執行精靈居中
  #--------------------------------------------------------------------------
  def center_sprite
    center_origin
    self.x = Graphics.width / 2
    self.y = Graphics.height / 2
  end
  #--------------------------------------------------------------------------
  # ● 執行精靈原點居中
  #--------------------------------------------------------------------------
  def center_origin
    if self.bitmap
      self.ox = self.bitmap.width / 2
      self.oy = self.bitmap.height / 2
    end
  end
  #--------------------------------------------------------------------------
  # ● 滑鼠是否在精靈內?
  #--------------------------------------------------------------------------
  def mouse_in_area?
    if self.bitmap
      Mouse.area?(self.x - self.ox,self.y - self.oy,self.bitmap.width,self.bitmap.height)
    else
      false
    end
  end
  #--------------------------------------------------------------------------
  # ● 當前位置
  #--------------------------------------------------------------------------
  def current_pos
    [self.x , self.y]
  end
  #--------------------------------------------------------------------------
  # ● 設定位置
  #--------------------------------------------------------------------------
  def set_pos(pos)
    self.x = pos[0]
    self.y = pos[1]
  end
end
#encoding:utf-8
#==============================================================================
# ■ SpriteDrawer
#------------------------------------------------------------------------------
#  讓精靈可以進行類似Window那樣繪製文字的模組
# UPDATE:14008062248 Ver 1.3
#==============================================================================
module SpriteDrawer
  #--------------------------------------------------------------------------
  # ● 取得視窗外框位圖
  #--------------------------------------------------------------------------
  def windowskin
    Cache.system("Window")
  end
  #--------------------------------------------------------------------------
  # ● 獲取內容尺寸
  #--------------------------------------------------------------------------
  def text_size(str)
    self.bitmap.text_size(str)
  end
  #--------------------------------------------------------------------------
  # ● 獲取項目的繪制矩形
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new
    rect.width = item_width
    rect.height = item_height
    rect.x = index % col_max * (item_width + spacing)
    rect.y = index / col_max * item_height
    rect
  end
  #--------------------------------------------------------------------------
  # ● 獲取項目寬度
  #--------------------------------------------------------------------------
  def item_width
    192
  end
  #--------------------------------------------------------------------------
  # ● 獲取項目高度
  #--------------------------------------------------------------------------
  def item_height
    line_height
  end
  #--------------------------------------------------------------------------
  # ● 獲取列數
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
  #--------------------------------------------------------------------------
  # ● 獲取行間距的寬度
  #--------------------------------------------------------------------------
  def spacing
    return 32
  end
  #--------------------------------------------------------------------------
  # ● 獲取文字顏色
  #     n : 文字顏色編號(0..31)
  #--------------------------------------------------------------------------
  def text_color(n)
    windowskin.get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
  end
  #--------------------------------------------------------------------------
  # ● 繪製文字
  #--------------------------------------------------------------------------
  def draw_text(*args,&block)
    self.bitmap.draw_text(*args,&block)
  end
  #--------------------------------------------------------------------------
  # ● 繪制圖標
  #     enabled : 有效的標志。false 的時候使用半透明效果繪制
  #--------------------------------------------------------------------------
  def draw_icon(icon_index, x, y, enabled = true)
    temp_bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    self.bitmap.blt(x, y, temp_bitmap, rect, enabled ? 255 : translucent_alpha)
  end
  #--------------------------------------------------------------------------
  # ● 繪制圖標,指定目標矩形
  #     enabled : 有效的標志。false 的時候使用半透明效果繪制
  #--------------------------------------------------------------------------
  def draw_icon_with_rect(icon_index,  target_rect ,enabled = true)
    temp_bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    self.bitmap.stretch_blt(target_rect, temp_bitmap, rect, enabled ? 255 : translucent_alpha)
  end
  #--------------------------------------------------------------------------
  # ● 獲取半透明繪制用的透明度
  #--------------------------------------------------------------------------
  def translucent_alpha
    return 160
  end
  #--------------------------------------------------------------------------
  # ● 繪制物品名稱
  #     enabled : 有效的標志。false 的時候使用半透明效果繪制
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y, enabled = true, width = 172)
    return unless item
    draw_icon(item.icon_index, x, y, enabled)
    change_color(normal_color, enabled)
    draw_text(x + 24, y, width, line_height, item.name)
  end
  #--------------------------------------------------------------------------
  # ● 繪制物品細節名稱 
  #--------------------------------------------------------------------------
  def draw_detail_name(item, x, y, enabled = true, width = 172)
    return unless item.is_a?(Game_Equip_Details)
    color = item.fmts[1]
    match_item = item.get_match
    return unless match_item
    item_name = sprintf(item.fmts[0],match_item.name)
    item_icon_index = match_item.icon_index
    if enabled
      change_color(text_color(color),true)
    else
      change_color(normal_color, false)
    end
    draw_icon(item_icon_index, x, y, enabled)
    draw_text(x + 24, y, width, line_height, item_name)
  end
  #--------------------------------------------------------------------------
  # ● 繪制名字
  #--------------------------------------------------------------------------
  def draw_actor_name(actor, x, y, width = 112,align = 0)
    # change_color(hp_color(actor))
    draw_text(x, y, width, line_height, actor.name,align)
  end
  #--------------------------------------------------------------------------
  # ● 更改內容繪制顏色
  #     enabled : 有效的標志。false 的時候使用半透明效果繪制
  #--------------------------------------------------------------------------
  def change_color(color, enabled = true)
    self.bitmap.font.color.set(color)
    self.bitmap.font.color.alpha = translucent_alpha unless enabled
  end
  #--------------------------------------------------------------------------
  # ● 更改字型
  #--------------------------------------------------------------------------
  def change_font(font)
    self.bitmap.font = font if self.bitmap
  end
  #--------------------------------------------------------------------------
  # ● 獲取行高
  #--------------------------------------------------------------------------
  def line_height
    return 24
  end
  #--------------------------------------------------------------------------
  # ● 更換字體大小
  #--------------------------------------------------------------------------
  def change_font_size(sz)
    self.bitmap.font.size = sz
  end
  #--------------------------------------------------------------------------
  # ● 繪製數值條內容 
  # 給定:座標、最大值、當前值、圖檔名稱
  #--------------------------------------------------------------------------
  def draw_gauge_content(dx,dy,current,max,filename)
    bitmap = Cache.battle(filename)
    rect = bitmap.rect.clone
    if max <= 0
      rate = 0
    else
      rate = (current.to_f/max)
    end
    rect.width = (rect.width * rate + 0.5).round
    self.bitmap.blt(dx,dy,bitmap,rect)
    change_color(normal_color)
    draw_text(dx,dy-3,bitmap.rect.width - 3,16,sprintf("%d / %d",current,max),2)
  end
  #--------------------------------------------------------------------------
  # ● 繪製子彈資訊
  #--------------------------------------------------------------------------
  def draw_bullet_info_by_detail(detail,x,y,dw = 115 , dh = 18)
    # 字型大小設置:子彈型
    change_font(Lctseng.bullet_font)
    
    item = nil
    if detail
      item = detail.get_match
    end
    if item && item.need_bullet?
      ammo = detail.ammo
      bullet_item = ammo.item
      if detail.has_loaded_bullet_id? && bullet_item
        draw_bullet(ammo,x,y,dw,dh)
      else
        change_color(system_color)
        draw_text(x,y,dw,dh,"無裝備任何子彈")
      end
    else
      # 子彈不存在或不需要子彈
      change_color(system_color)
      draw_text(x,y,dw,dh,"無須使用子彈")
    end
    
  end
  #--------------------------------------------------------------------------
  # ● 繪製子彈
  #--------------------------------------------------------------------------
  def draw_bullet(ammo,x,y,total_dw,dh)
    amount_dw = 40
    dw = total_dw - amount_dw
    item = ammo.item
    bullet = ammo.bullet_obj
    # 繪製圖標
    draw_icon_with_rect(item.icon_index,Rect.new(x,y,dh,dh))
    # 基準座標位移
    diff = (dh + 1)
    x += diff
    dw -= diff
    # 繪製文字
    
    change_color(text_color(6))
    name = bullet.display_name
    text_w = text_size(name).width
    #contents.fill_rect(Rect.new(x,y,dw,dh),Color.new(255,0,0))
    draw_text(x,y,dw,dh,name)
    
    # 基準座標位移
    x += ( text_w + 1 )
    # 繪製數量
    amount = ammo.bullet_remain
    if amount > 0
      change_color(Color.new(0,255,0))
    else
      change_color(Color.new(255,0,0))
    end
    str = sprintf("(%d)",amount)
    #contents.fill_rect(Rect.new(x,y,amount_dw,dh),Color.new(255,255,0))
    draw_text(x,y,amount_dw,dh,str)
    
  end
  #--------------------------------------------------------------------------
  # ● 獲取能力值變化的繪制色
  #--------------------------------------------------------------------------
  def param_change_color(change)
    return power_up_color   if change > 0
    return power_down_color if change < 0
    return normal_color
  end
  #--------------------------------------------------------------------------
  # ● 獲取各種文字顏色
  #--------------------------------------------------------------------------
  def normal_color;      text_color(0);   end;    # 普通
  def system_color;      text_color(16);  end;    # 系統
  def crisis_color;      text_color(17);  end;    # 危險
  def knockout_color;    text_color(18);  end;    # 無法戰斗
  def gauge_back_color;  text_color(19);  end;    # 值槽背景
  def hp_gauge_color1;   text_color(20);  end;    # HP 值槽 1
  def hp_gauge_color2;   text_color(21);  end;    # HP 值槽 2
  def mp_gauge_color1;   text_color(22);  end;    # MP 值槽 1
  def mp_gauge_color2;   text_color(23);  end;    # MP 值槽 2
  def mp_cost_color;     text_color(23);  end;    # 消費 TP
  def power_up_color;    text_color(24);  end;    # 能力值提升(更換裝備時)
  def power_down_color;  text_color(25);  end;    # 能力值降低(更換裝備時)
  def tp_gauge_color1;   text_color(28);  end;    # TP 值槽 1
  def tp_gauge_color2;   text_color(29);  end;    # TP 值槽 2
  def tp_cost_color;     text_color(29);  end;    # 消費 TP
  end
  
  
  
  #encoding:utf-8
#==============================================================================
# ■ SpriteFader
#------------------------------------------------------------------------------
#  讓精靈可以進行淡出淡入所需的原件
#==============================================================================
module SpriteFader
  #--------------------------------------------------------------------------
  # ● 初始化淡入淡出模組
  #--------------------------------------------------------------------------
  def fader_init
    @fade_count = 0
    @fade_to = 0
    @fade_real_opacity = 0.0
    @fade_speed = 0.0
    @fade_post_handler = nil
    @fade_init = true
    @fade_processing = false
  end
  #--------------------------------------------------------------------------
  # ● 設置淡入淡出 (設定目的透明度與時間)
  #--------------------------------------------------------------------------
  def fader_set_fade(to,time)
    @fade_count = time
    @fade_to = to.to_f
    @fade_real_opacity = self.opacity.to_f
    @fade_speed = ( @fade_to - @fade_real_opacity ) / @fade_count + 0.001
    @fade_processing = true
  end
  #--------------------------------------------------------------------------
  # ● 更新淡入淡出
  #--------------------------------------------------------------------------
  def fader_update
    return if !@fade_init
    if @fade_count > 0
      @fade_count -= 1
      self.opacity = @fade_real_opacity += @fade_speed
    else
      if @fade_processing
        @fade_processing = false
        fader_post_fade
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 是否淡入淡出?
  #--------------------------------------------------------------------------
  def fader_fading?
    @fade_init && @fade_count > 0
  end
  #--------------------------------------------------------------------------
  # ● 設置淡入淡出結束後處理
  #--------------------------------------------------------------------------
  def fader_set_post_handler(handler)
    @fade_post_handler = handler
  end
  #--------------------------------------------------------------------------
  # ● 呼叫淡入淡出結束後處理
  #--------------------------------------------------------------------------
  def fader_post_fade
    if @fade_post_handler
      @fade_post_handler.call
    end
  end
  #--------------------------------------------------------------------------
  # ● 清除呼叫淡入淡出結束後的處理程序
  #--------------------------------------------------------------------------
  def fader_clear_handler
    @fade_post_handler = nil
  end
end
#encoding:utf-8
#==============================================================================
# ■ SpriteSlider
#------------------------------------------------------------------------------
#  讓精靈可以進行移動所需的原件
#  UPDATE:1407091114
#==============================================================================
module SpriteSlider
  #--------------------------------------------------------------------------
  # ● 初始化移動模組
  #--------------------------------------------------------------------------
  def slider_init
    @slide_count = 0
    @slide_real_pos = [0.0,0.0]
    @slide_from = [0,0]
    @slide_to = [0,0]
    @slide_speed = [0.0,0.0]
    @slide_init = true
    @slide_post_handler = nil
    @slide_processing = false
  end
  #--------------------------------------------------------------------------
  # ● 設置移動
  #--------------------------------------------------------------------------
  def slider_set_move(from,to,time)
    @slide_count = time
    @slide_from = from.collect {|i| i.to_f}
    @slide_to = to.collect {|i| i.to_f}
    @slide_real_pos = @slide_from.clone
    # 設置速度
    2.times do |i|
      @slide_speed[i] = (@slide_to[i] - @slide_from[i]) / @slide_count
    end
    @slide_processing = true
    
  end
  #--------------------------------------------------------------------------
  # ● 更新移動
  #--------------------------------------------------------------------------
  def slider_update
    return if !@slide_init
    if @slide_count > 0
      @slide_count -= 1
      2.times do |i|
        @slide_real_pos[i] = @slide_real_pos[i] + @slide_speed[i]
      end
      self.x = @slide_real_pos[0]
      self.y = @slide_real_pos[1]
    else
      if @slide_processing
        slider_adjust_pos
        @slide_processing = false
        slider_post_method
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 修正最後位置
  #--------------------------------------------------------------------------
  def slider_adjust_pos
    self.x , self.y = @slide_to
  end
  #--------------------------------------------------------------------------
  # ● 是否移動動?
  #--------------------------------------------------------------------------
  def slider_sliding?
    @slide_init && @slide_count > 0
  end
  #--------------------------------------------------------------------------
  # ● 呼叫移動後的方法
  #--------------------------------------------------------------------------
  def slider_post_method
    if @slide_post_handler
      @slide_post_handler.call
    end
  end
  #--------------------------------------------------------------------------
  # ● 設置移動結束後處理
  #--------------------------------------------------------------------------
  def slider_set_post_handler(handler)
    @slide_post_handler = handler
  end
  #--------------------------------------------------------------------------
  # ● 清除呼叫移動出結束後的處理程序
  #--------------------------------------------------------------------------
  def slider_clear_handler
    @slide_post_handler = nil
  end
  #--------------------------------------------------------------------------
  # ● 清除呼叫移動出結束後的處理程序
  #--------------------------------------------------------------------------
  def slider_clear_post_handler
    @slide_post_handler = nil
  end
end
#encoding:utf-8
#==============================================================================
# ■ SpriteSensor
# 更新:1408061703 Ver 1.1
#------------------------------------------------------------------------------
#  讓精靈可以感應滑鼠放置所需的原件
#==============================================================================
module SpriteSensor
  #--------------------------------------------------------------------------
  # ● 初始化感應模組
  #--------------------------------------------------------------------------
  def sensor_init
    @sensor_init = true
    @sensor_hover_handler = nil
    @sensor_input_handler = nil
    @sensor_set_hover = false
    @sensor_set_input = false
    @active = false
  end
  #--------------------------------------------------------------------------
  # ● 其他啟動條件
  #--------------------------------------------------------------------------
  def sensor_other_active_condition
    true
  end
  #--------------------------------------------------------------------------
  # ● 啟用感應器
  #--------------------------------------------------------------------------
  def sensor_activate
    @active = true
  end
  #--------------------------------------------------------------------------
  # ● 停用感應器
  #--------------------------------------------------------------------------
  def sensor_deactivate
    @active = false
  end
  #--------------------------------------------------------------------------
  # ● 設置懸浮感應處理程序
  #--------------------------------------------------------------------------
  def sensor_set_sense_hover(handler)
    @sensor_set_hover = true
    @sensor_hover_handler = handler
  end
  #--------------------------------------------------------------------------
  # ● 設置按鈕感應處理程序
  #--------------------------------------------------------------------------
  def sensor_set_sense_input(handler)
    @sensor_set_input = true
    @sensor_input_handler = handler
  end
  #--------------------------------------------------------------------------
  # ● 滑鼠是否在精靈內?
  #--------------------------------------------------------------------------
  def sensor_mouse_in_area?
    if self.bitmap
      Mouse.area?(self.x - self.ox,self.y - self.oy,self.bitmap.width,self.bitmap.height)
    else
      false
    end
  end
  #--------------------------------------------------------------------------
  # ● 呼叫感應器的檢查方法
  #--------------------------------------------------------------------------
  def sensor_call_input
    if Input.trigger?(:C)
      @sensor_input_handler.call(:C)
    end
  end
  #--------------------------------------------------------------------------
  # ● 滑鼠是否在精靈內?包含啟動測試
  #--------------------------------------------------------------------------
  def sensor_mouse_in_area_safe?
    @sensor_init  && @active && sensor_mouse_in_area?
  end
  #--------------------------------------------------------------------------
  # ● 更新感應
  #--------------------------------------------------------------------------
  def sensor_update
    return if !@sensor_init 
    return if !@active
    return if !sensor_other_active_condition
    if @sensor_hover_handler
      if sensor_mouse_in_area?
        if @sensor_set_hover && @sensor_hover_handler
          @sensor_hover_handler.call(true)
        end
        if @sensor_set_input && @sensor_input_handler
          sensor_call_input
        end
      else
        if @sensor_set_hover && @sensor_hover_handler
          @sensor_hover_handler.call(false)
        end
      end
    end
  end
end
#encoding:utf-8
#==============================================================================
# ■ SpriteZoomer
#------------------------------------------------------------------------------
#  讓精靈可以進行放大縮小所需的原件,內部實例變數以 "_" 開頭,公開方法以"zoomer"開頭
#==============================================================================
module SpriteZoomer
  #--------------------------------------------------------------------------
  # ● 初始化縮放模組
  #--------------------------------------------------------------------------
  def zoomer_init
    @_zoom_count = 0
    @_zoom_from = [0.0,0.0]
    @_zoom_to = [0.0,0.0]
    @_zoom_speed = [0.0,0.0]
    @_zoom_init = true
    @_zoom_post_handler = nil
    @_zoom_processing = false
  end
  #--------------------------------------------------------------------------
  # ● 設置縮放
  #--------------------------------------------------------------------------
  def zoomer_set_effect(from,to,time)
    self.zoom_x , self.zoom_y = from
    @_zoom_count = time
    @_zoom_from = from
    @_zoom_to = to
    # 設置速度
    2.times do |i|
      @_zoom_speed[i] = (@_zoom_to[i] - @_zoom_from[i]) / @_zoom_count
    end
    @_zoom_processing = true
    
  end
  #--------------------------------------------------------------------------
  # ● 更新縮放
  #--------------------------------------------------------------------------
  def zoomer_update
    return if !@_zoom_init
    if @_zoom_count > 0
      @_zoom_count -= 1
      self.zoom_x += @_zoom_speed[0]
      self.zoom_y += @_zoom_speed[1]
    else
      if @_zoom_processing
        @_zoom_processing = false
        zoomer_post_method
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 是否效果中?
  #--------------------------------------------------------------------------
  def zoomer_effect?
    @_zoom_init && @_zoom_count > 0
  end
  #--------------------------------------------------------------------------
  # ● 呼叫縮放後的方法
  #--------------------------------------------------------------------------
  def zoomer_post_method
    if @_zoom_post_handler
      @_zoom_post_handler.call
    end
  end
  #--------------------------------------------------------------------------
  # ● 設置縮放結束後處理
  #--------------------------------------------------------------------------
  def zoomer_set_post_handler(handler)
    @_zoom_post_handler = handler
  end
  #--------------------------------------------------------------------------
  # ● 清除呼叫縮放出結束後的處理程序
  #--------------------------------------------------------------------------
  def zoomer_clear_handler
    @_zoom_post_handler = nil
  end
end
 | 
 |