Project1

标题: 立绘系统发生no method error [打印本页]

作者: Kim_巧克力控    时间: 2016-10-31 23:08
标题: 立绘系统发生no method error
脚本作者是lctseng,
游戏运行时发生了no method error







求各位大触帮帮忙 感恩!

作者: cinderelmini    时间: 2016-11-1 12:24
代码不完全……
只能初步判断这个实例变量的值的那个类里并没有这个方法…………
作者: Kim_巧克力控    时间: 2016-11-1 21:23
  1. #encoding:utf-8

  2. =begin
  3. *******************************************************************************************

  4.    * 立繪系統 *

  5.                        for RGSS3

  6.         Ver 1.2   2016.08.29

  7.    原作者:魂(Lctseng),巴哈姆特論壇ID:play123


  8.    轉載請保留此標籤

  9.    個人小屋連結:http://home.gamer.com.tw/homeindex.php?owner=play123

  10.    需求前置腳本:Lctseng - 圖像精靈強化
  11.    請將此腳本至於該腳本底下

  12.    主要功能:
  13.                        一、顯示左右邊的立繪,與對話框分開(即沒有關聯)


  14.    更新紀錄:
  15.     Ver 1.00 :
  16.     日期:2014.09.24
  17.     摘要:■、最初版本


  18.     Ver 1.10 :
  19.     日期:2014.10.30
  20.     摘要:■、加入調整透明度的功能


  21.     Ver 1.11 :
  22.     日期:2014.11.05
  23.     摘要:■、修正立即出現沒有調整透明度的錯誤

  24.     Ver 1.2 :
  25.     日期:2016.08.29
  26.     摘要:■、移除對話框行數多一行的部分


  27.     撰寫摘要:一、此腳本修改或重新定義以下類別:
  28.                            ■ Game_Interpreter
  29.                            ■ Game_System
  30.                            ■ Scene_Base
  31.                            ■ Scene_Map

  32.                         二、此腳本新定義以下類別和模組:
  33.                            ■ Lctseng::Game_StandController
  34.                            ■ Lctseng::Game_Stand
  35.                            ■ Lctseng::Game_LeftStand
  36.                            ■ Lctseng::Game_RightStand
  37.                            ■ Lctseng::Spriteset_Stand
  38.                            ■ Lctseng::Sprite_Stand
  39.                            ■ Lctseng::Sprite_LeftStand
  40.                            ■ Lctseng::Sprite_RightStand


  41. *******************************************************************************************
  42. =end


  43. #*******************************************************************************************
  44. #
  45. #   請勿修改從這裡以下的程式碼,除非你知道你在做什麼!
  46. #   DO NOT MODIFY UNLESS YOU KNOW WHAT TO DO !
  47. #
  48. #*******************************************************************************************

  49. #--------------------------------------------------------------------------
  50. # ★ 紀錄腳本資訊
  51. #--------------------------------------------------------------------------
  52. if !$lctseng_scripts
  53.   $lctseng_scripts = {}
  54. end

  55. ## 檢查前置腳本
  56. if !$lctseng_scripts[:sprite_ex]
  57.   msgbox("沒有發現前置腳本:Lctseng - 圖像精靈強化\n或者是腳本位置錯誤!\n程式即將關閉")
  58.   exit
  59. end


  60. $lctseng_scripts[:stand_picture] = "1.11"

  61. puts "載入腳本:Lctseng - 立繪系統,版本:#{$lctseng_scripts[:stand_picture]}"



  62. #encoding:utf-8
  63. #==============================================================================
  64. # ■ Game_Interpreter
  65. #------------------------------------------------------------------------------
  66. #  事件指令的解釋器。
  67. #   本類在 Game_Map、Game_Troop、Game_Event 類的內部使用。
  68. #==============================================================================

  69. class Game_Interpreter
  70.   #--------------------------------------------------------------------------
  71.   # ● 左圖片飛入
  72.   #--------------------------------------------------------------------------
  73.   def left_slide_in(*args)
  74.     $game_system.stand.left_slide_in(*args)
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 左圖片飛出
  78.   #--------------------------------------------------------------------------
  79.   def left_slide_out(*args)
  80.     $game_system.stand.left_slide_out(*args)
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● 左圖片更換
  84.   #--------------------------------------------------------------------------
  85.   def left_change(*args)
  86.     $game_system.stand.left_change(*args)
  87.   end

  88.   #--------------------------------------------------------------------------
  89.   # ● 右圖片飛入
  90.   #--------------------------------------------------------------------------
  91.   def right_slide_in(*args)
  92.     $game_system.stand.right_slide_in(*args)
  93.   end
  94.   #--------------------------------------------------------------------------
  95.   # ● 右圖片飛出
  96.   #--------------------------------------------------------------------------
  97.   def right_slide_out(*args)
  98.     $game_system.stand.right_slide_out(*args)
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 右圖片更換
  102.   #--------------------------------------------------------------------------
  103.   def right_change(*args)
  104.     $game_system.stand.right_change(*args)
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # ● 左圖片Z座標更換
  108.   #--------------------------------------------------------------------------
  109.   def left_z(val)
  110.     $game_system.stand.left.z = val
  111.   end
  112.   #--------------------------------------------------------------------------
  113.   # ● 右圖片Z座標更換
  114.   #--------------------------------------------------------------------------
  115.   def right_z(val)
  116.     $game_system.stand.right.z = val
  117.   end
  118.   #--------------------------------------------------------------------------
  119.   # ● 左圖片在對話框前
  120.   #--------------------------------------------------------------------------
  121.   def left_front
  122.     left_z(500)
  123.   end
  124.   #--------------------------------------------------------------------------
  125.   # ● 左圖片在對話框後
  126.   #--------------------------------------------------------------------------
  127.   def left_behind
  128.     left_z(50)
  129.   end
  130.   #--------------------------------------------------------------------------
  131.   # ● 右圖片在對話框前
  132.   #-------------------------------------------------------------------------
  133.   def right_front
  134.     right_z(500)
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # ● 右圖片在對話框後
  138.   #--------------------------------------------------------------------------
  139.   def right_behind
  140.     right_z(50)
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 左圖片最大透明限制
  144.   #--------------------------------------------------------------------------
  145.   def left_limit_opacity(*args)
  146.     $game_system.stand.left_limit_opacity(*args)
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● 右圖片最大透明限制
  150.   #--------------------------------------------------------------------------
  151.   def right_limit_opacity(*args)
  152.     $game_system.stand.right_limit_opacity(*args)
  153.   end

  154. end


  155. #encoding:utf-8
  156. #==============================================================================
  157. # ■ Game_System
  158. #------------------------------------------------------------------------------
  159. #  處理系統附屬數據的類。保存存檔和菜單的禁止狀態之類的數據。
  160. #   本類的實例請參考 $game_system 。
  161. #==============================================================================

  162. class Game_System
  163.   #--------------------------------------------------------------------------
  164.   # ● 取得立繪控制物件
  165.   #--------------------------------------------------------------------------
  166.   def stand
  167.     [url=home.php?mod=space&uid=33296]@stand[/url] ||= Lctseng::Game_StandController.new
  168.   end
  169. end

  170. #encoding:utf-8
  171. #==============================================================================
  172. # ■ Lctseng::Game_StandController
  173. #------------------------------------------------------------------------------
  174. #  控制立繪物件
  175. #==============================================================================

  176. module Lctseng
  177. class Game_StandController
  178.   #--------------------------------------------------------------------------
  179.   # ● 定義實例變數
  180.   #--------------------------------------------------------------------------
  181.   attr_reader :left
  182.   attr_reader :right
  183.   #--------------------------------------------------------------------------
  184.   # ● 初始化對象
  185.   #--------------------------------------------------------------------------
  186.   def initialize
  187.     [url=home.php?mod=space&uid=456159]@left[/url] = Game_LeftStand.new
  188.     @right = Game_RightStand.new
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ● 當精靈組被釋放的時候的處理
  192.   #--------------------------------------------------------------------------
  193.   def on_terminate
  194.     # 全部飛出
  195.     left_slide_out
  196.     right_slide_out
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 左圖片飛入
  200.   #--------------------------------------------------------------------------
  201.   def left_slide_in(filename)
  202.     @left.change_filename(filename)
  203.     @left.slide_in_req
  204.   end
  205.   #--------------------------------------------------------------------------
  206.   # ● 左圖片飛出
  207.   #--------------------------------------------------------------------------
  208.   def left_slide_out
  209.     @left.slide_out_req
  210.   end
  211.   #--------------------------------------------------------------------------
  212.   # ● 左圖片最大透明限制
  213.   #--------------------------------------------------------------------------
  214.   def left_limit_opacity(value)
  215.     @left.limit_opacity(value)
  216.   end
  217.   #--------------------------------------------------------------------------
  218.   # ● 右圖片飛入
  219.   #--------------------------------------------------------------------------
  220.   def right_slide_in(filename)
  221.     @right.change_filename(filename)
  222.     @right.slide_in_req
  223.   end
  224.   #--------------------------------------------------------------------------
  225.   # ● 右圖片飛出
  226.   #--------------------------------------------------------------------------
  227.   def right_slide_out
  228.     @right.slide_out_req
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # ● 右圖片最大透明限制
  232.   #--------------------------------------------------------------------------
  233.   def right_limit_opacity(value)
  234.     @right.limit_opacity(value)
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # ● 左圖片更換
  238.   #--------------------------------------------------------------------------
  239.   def left_change(filename,fast = false)
  240.     @left.change(filename,fast)
  241.   end
  242.   #--------------------------------------------------------------------------
  243.   # ● 右圖片更換
  244.   #--------------------------------------------------------------------------
  245.   def right_change(filename,fast = false)
  246.     @right.change(filename,fast)
  247.   end
  248. end
  249. end

  250. #encoding:utf-8
  251. #==============================================================================
  252. # ■ Lctseng::Game_Stand
  253. #------------------------------------------------------------------------------
  254. #  立繪物件
  255. #==============================================================================

  256. module Lctseng
  257. class Game_Stand
  258.   #--------------------------------------------------------------------------
  259.   # ● 定義實例變數
  260.   #--------------------------------------------------------------------------
  261.   attr_reader :status
  262.   attr_reader :filename
  263.   attr_reader :new_filename
  264.   attr_reader :old_filename
  265.   attr_reader :change_fast
  266.   attr_reader :opacity_limit
  267.   attr_accessor :z
  268.   #--------------------------------------------------------------------------
  269.   # ● 初始化對象
  270.   #--------------------------------------------------------------------------
  271.   def initialize
  272.     # 檔名
  273.     @filename = ''
  274.     # 狀態:
  275.     # :none 無
  276.     # :slide_in_req 要求飛入
  277.     # :sliding_in   飛入中
  278.     # slide_out_req  要求飛出
  279.     # :sliding_out  飛出中
  280.     # :show 顯示中
  281.     # :change_req 要求更換
  282.     # :changing 更換中
  283.     @status = :none
  284.     # 更換時的新檔名【僅show中更換時生效】
  285.     @new_filename = ''
  286.     # 更換時的舊檔名【僅show中更換時生效】
  287.     @old_filename = ''
  288.     # 更換時是否快速更換,代表立即顯示不淡入
  289.     @change_fast = false
  290.     #  Z 座標
  291.     @z = 300
  292.     # 透明度最大限制
  293.     @opacity_limit = 255
  294.   end

  295.   #--------------------------------------------------------------------------
  296.   # ● 回應飛入要求
  297.   #--------------------------------------------------------------------------
  298.   def response_slide_in
  299.     @status = :sliding_in
  300.   end
  301.   #--------------------------------------------------------------------------
  302.   # ● 回應飛入結束
  303.   #--------------------------------------------------------------------------
  304.   def response_slide_in_end
  305.     @status = :show
  306.   end
  307.   #--------------------------------------------------------------------------
  308.   # ● 回應飛出要求
  309.   #--------------------------------------------------------------------------
  310.   def response_slide_out
  311.     @status = :sliding_out
  312.   end
  313.   #--------------------------------------------------------------------------
  314.   # ● 回應飛出結束
  315.   #--------------------------------------------------------------------------
  316.   def response_slide_out_end
  317.     @status = :none
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # ● 回應更換要求
  321.   #--------------------------------------------------------------------------
  322.   def response_change_req
  323.     @status = :changing
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 回應更換結束
  327.   #--------------------------------------------------------------------------
  328.   def response_change_end
  329.     @status = :show
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # ● 檔名更換
  333.   #--------------------------------------------------------------------------
  334.   def change_filename(new_name)
  335.     @old_filename = @filename
  336.     @new_filename = @filename = new_name
  337.   end
  338.   #--------------------------------------------------------------------------
  339.   # ● 切換
  340.   #--------------------------------------------------------------------------
  341.   def change(new_name,fast)
  342.     @change_fast = fast
  343.     change_filename(new_name)
  344.     @status = :change_req
  345.   end
  346.   #--------------------------------------------------------------------------
  347.   # ● 要求飛入
  348.   #--------------------------------------------------------------------------
  349.   def slide_in_req
  350.     @status = :slide_in_req
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # ● 要求飛出
  354.   #--------------------------------------------------------------------------
  355.   def slide_out_req
  356.     @status = :slide_out_req if @status != :none
  357.   end
  358.   #--------------------------------------------------------------------------
  359.   # ● 限制透明度
  360.   #--------------------------------------------------------------------------
  361.   def limit_opacity(value)
  362.     @opacity_limit = value
  363.   end

  364. end
  365. end

  366. #encoding:utf-8
  367. #==============================================================================
  368. # ■ Lctseng::Game_LeftStand
  369. #------------------------------------------------------------------------------
  370. #  左方立繪物件
  371. #==============================================================================

  372. module Lctseng
  373. class Game_LeftStand < Game_Stand
  374.   #--------------------------------------------------------------------------
  375.   # ● 初始化對象
  376.   #--------------------------------------------------------------------------
  377.   def initialize
  378.     super
  379.   end


  380. end
  381. end

  382. #encoding:utf-8
  383. #==============================================================================
  384. # ■ Lctseng::Game_RightStand
  385. #------------------------------------------------------------------------------
  386. #  右方立繪物件
  387. #==============================================================================

  388. module Lctseng
  389. class Game_RightStand < Game_Stand
  390.   #--------------------------------------------------------------------------
  391.   # ● 初始化對象
  392.   #--------------------------------------------------------------------------
  393.   def initialize
  394.     super
  395.   end


  396. end
  397. end

  398. #encoding:utf-8
  399. #==============================================================================
  400. # ■ Lctseng::Spriteset_Stand
  401. #------------------------------------------------------------------------------
  402. #     處理立繪的精靈組
  403. #     監視Game_StandController進行立繪處理
  404. #==============================================================================
  405. module Lctseng
  406. class Spriteset_Stand
  407.   #--------------------------------------------------------------------------
  408.   # ● 加入設定模組
  409.   #--------------------------------------------------------------------------
  410.   #--------------------------------------------------------------------------
  411.   # ● 初始化對象
  412.   #--------------------------------------------------------------------------
  413.   def initialize(viewport)
  414.     @viewport = viewport
  415.     @terminating_count = 0
  416.     create_sprites
  417.   end
  418.   #--------------------------------------------------------------------------
  419.   # ● 取得控制器
  420.   #--------------------------------------------------------------------------
  421.   def control
  422.     $game_system.stand
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ● 產生精靈
  426.   #--------------------------------------------------------------------------
  427.   def create_sprites
  428.     @left = Lctseng::Sprite_LeftStand.new(@viewport)
  429.     @right = Lctseng::Sprite_RightStand.new(@viewport)
  430.   end
  431.   #--------------------------------------------------------------------------
  432.   # ● 釋放
  433.   #--------------------------------------------------------------------------
  434.   def dispose
  435.     dispose_sprites
  436.   end
  437.   #--------------------------------------------------------------------------
  438.   # ● 釋放精靈
  439.   #--------------------------------------------------------------------------
  440.   def dispose_sprites
  441.     @left.dispose
  442.     @right.dispose
  443.   end
  444.   #--------------------------------------------------------------------------
  445.   # ● 釋放
  446.   #--------------------------------------------------------------------------
  447.   def any_sprite_show?
  448.     return true if @left&&@left.control.status != :none
  449.     return true if @right&&@right.control.status != :none
  450.     return false
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # ● 更新
  454.   #--------------------------------------------------------------------------
  455.   def update
  456.     update_sprites
  457.   end
  458.   #--------------------------------------------------------------------------
  459.   # ● 更新精靈
  460.   #--------------------------------------------------------------------------
  461.   def update_sprites
  462.     @left.update
  463.     @right.update
  464.   end
  465.   #--------------------------------------------------------------------------
  466.   # ● 結束計數
  467.   #--------------------------------------------------------------------------
  468.   def terminate_countdown
  469.     @terminating_count -= 1
  470.   end

  471.   #--------------------------------------------------------------------------
  472.   # ● 結束中?
  473.   #--------------------------------------------------------------------------
  474.   def terminating?
  475.     @terminating_count > 0
  476.   end
  477.   #--------------------------------------------------------------------------
  478.   # ● 終止
  479.   #--------------------------------------------------------------------------
  480.   def terminate
  481.     puts "終止處理"
  482.     control.on_terminate
  483.     if any_sprite_show?
  484.       puts "要求終止前顯示"
  485.       @terminating_count  = 35
  486.     end
  487.   end

  488. end
  489. end

  490. #encoding:utf-8
  491. #==============================================================================
  492. # ■ Lctseng::Sprite_Stand
  493. #------------------------------------------------------------------------------
  494. #     立繪精靈
  495. #==============================================================================
  496. module Lctseng
  497. class Sprite_Stand < Sprite_Base
  498.   #--------------------------------------------------------------------------
  499.   # ● 加入淡入淡出與移動模組
  500.   #--------------------------------------------------------------------------
  501.   include SpriteFader
  502.   include SpriteSlider
  503.   #--------------------------------------------------------------------------
  504.   # ● 初始化對象
  505.   #--------------------------------------------------------------------------
  506.   def initialize(viewport)
  507.     @opacity_limit = 255
  508.     @origin_opacity = 255
  509.     super(viewport)
  510.     @origin_opacity = self.opacity
  511.     @filename = ''
  512.     check_opacity
  513.     fader_init
  514.     slider_init
  515.     [url=home.php?mod=space&uid=31758]@Shadow[/url] = Sprite_StandShadow.new(self,viewport)
  516.   end
  517.   #--------------------------------------------------------------------------
  518.   # ● 取得控制物件
  519.   #--------------------------------------------------------------------------
  520.   def control
  521.   end
  522.   #--------------------------------------------------------------------------
  523.   # ● 更新
  524.   #--------------------------------------------------------------------------
  525.   def update
  526.     super
  527.     check_opacity
  528.     check_action
  529.     fader_update
  530.     slider_update
  531.     self.z = control.z
  532.     @shadow.update
  533.   end
  534.   #--------------------------------------------------------------------------
  535.   # ● 設定透明度
  536.   #--------------------------------------------------------------------------
  537.   alias :set_opacity :opacity=
  538.   #--------------------------------------------------------------------------
  539.   def opacity=(val)
  540.     @origin_opacity = val
  541.     adj = [@origin_opacity,@opacity_limit].min
  542.     set_opacity(adj)
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ● 檢查透明度
  546.   #--------------------------------------------------------------------------
  547.   def check_opacity
  548.     if  @opacity_limit != control.opacity_limit
  549.       @opacity_limit = control.opacity_limit
  550.       self.opacity = @origin_opacity
  551.     end
  552.   end
  553.   #--------------------------------------------------------------------------
  554.   # ● 檢查動作
  555.   #--------------------------------------------------------------------------
  556.   def check_action
  557.     #puts "狀態:#{control.status}"
  558.     case control.status
  559.     when :none
  560.       hide
  561.     when :slide_in_req
  562.       check_filename
  563.       reset_position
  564.       slide_in
  565.       control.response_slide_in
  566.     when :sliding_in
  567.       if !slider_sliding?
  568.         control.response_slide_in_end
  569.       end
  570.     when :slide_out_req
  571.       slide_out
  572.       control.response_slide_out
  573.     when :sliding_out
  574.       if !slider_sliding?
  575.         control.response_slide_out_end
  576.       end
  577.     when :change_req
  578.       if control.change_fast
  579.         change_immediately
  580.         control.response_change_end
  581.       else
  582.         setup_shadow
  583.         control.response_change_req
  584.       end
  585.     when :changing
  586.       if !fader_fading? && [email protected]_fading?
  587.         control.response_change_end
  588.       end
  589.     end
  590.   end
  591.   #--------------------------------------------------------------------------
  592.   # ● 隱藏
  593.   #--------------------------------------------------------------------------
  594.   def hide
  595.     self.opacity = 0
  596.   end
  597.   #--------------------------------------------------------------------------
  598.   # ● 檢查檔名
  599.   #--------------------------------------------------------------------------
  600.   def check_filename
  601.     # 若檔案更換,則重新建立位圖
  602.     if @filename != control.filename
  603.       change_immediately
  604.     end
  605.   end
  606.   #--------------------------------------------------------------------------
  607.   # ● 重置位置
  608.   #--------------------------------------------------------------------------
  609.   def reset_position
  610.     return unless self.bitmap
  611.     set_pos(slided_out_pos)
  612.   end
  613.   #--------------------------------------------------------------------------
  614.   # ● 取得已飛入的位置
  615.   #--------------------------------------------------------------------------
  616.   def slided_in_pos
  617.     [0,Graphics.height - self.height]
  618.   end
  619.   #--------------------------------------------------------------------------
  620.   # ● 取得已飛出的位置
  621.   #--------------------------------------------------------------------------
  622.   def slided_out_pos
  623.     [-0.5 * self.width,Graphics.height - self.height]
  624.   end
  625.   #--------------------------------------------------------------------------
  626.   # ● 釋放
  627.   #--------------------------------------------------------------------------
  628.   def dispose
  629.     super
  630.     @shadow.dispose
  631.   end
  632.   #--------------------------------------------------------------------------
  633.   # ● 飛入顯示
  634.   #--------------------------------------------------------------------------
  635.   def slide_in
  636.     fader_set_fade(255,30)
  637.     slider_set_move(current_pos,slided_in_pos,30)
  638.   end
  639.   #--------------------------------------------------------------------------
  640.   # ● 飛出隱藏
  641.   #--------------------------------------------------------------------------
  642.   def slide_out
  643.     fader_set_fade(0,30)
  644.     slider_set_move(current_pos,slided_out_pos,30)
  645.   end
  646.   #--------------------------------------------------------------------------
  647.   # ● 立即更換
  648.   #--------------------------------------------------------------------------
  649.   def change_immediately
  650.     @filename = control.filename
  651.     self.bitmap = Cache.picture(@filename)
  652.     # 重新對齊座標
  653.     set_pos(slide_in_pos_adjust(slided_in_pos))
  654.     # 設定透明度
  655.     self.opacity = 255
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # ● 設置陰影
  659.   # 將舊圖片作為殘影,主精靈使用新圖片淡入
  660.   #--------------------------------------------------------------------------
  661.   def setup_shadow
  662.     @shadow.setup
  663.     change_immediately
  664.     self.opacity = 0
  665.     fader_set_fade(255,30)
  666.   end
  667.   #--------------------------------------------------------------------------
  668.   # ● 已飛入位置調整
  669.   #--------------------------------------------------------------------------
  670.   def slide_in_pos_adjust(pos)
  671.     pos
  672.   end
  673. end
  674. end

  675. #encoding:utf-8
  676. #==============================================================================
  677. # ■ Lctseng::Sprite_StandShadow
  678. #------------------------------------------------------------------------------
  679. #     立繪陰影精靈,主精靈更換圖片時,用來淡出舊圖片
  680. #==============================================================================
  681. module Lctseng
  682. class Sprite_StandShadow < Sprite_Base
  683.   #--------------------------------------------------------------------------
  684.   # ● 加入淡入淡出與移動模組
  685.   #--------------------------------------------------------------------------
  686.   include SpriteFader
  687.   #--------------------------------------------------------------------------
  688.   # ● 初始化對象
  689.   #--------------------------------------------------------------------------
  690.   def initialize(main,viewport)
  691.     super(viewport)
  692.     [url=home.php?mod=space&uid=217648]@Main[/url] = main
  693.     fader_init
  694.   end

  695.   #--------------------------------------------------------------------------
  696.   # ● 更新
  697.   #--------------------------------------------------------------------------
  698.   def update
  699.     super
  700.     fader_update
  701.   end
  702.   #--------------------------------------------------------------------------
  703.   # ● 設置
  704.   #--------------------------------------------------------------------------
  705.   def setup
  706.     self.bitmap = Cache.picture(@main.control.old_filename)
  707.     self.opacity = @main.opacity
  708.     self.x = @main.x
  709.     self.y = @main.y
  710.     fader_set_fade(0,30)
  711.   end
  712. end
  713. end


  714. #encoding:utf-8
  715. #==============================================================================
  716. # ■ Lctseng::Sprite_LeftStand
  717. #------------------------------------------------------------------------------
  718. #     左方立繪精靈
  719. #==============================================================================
  720. module Lctseng
  721. class Sprite_LeftStand < Sprite_Stand
  722.   #--------------------------------------------------------------------------
  723.   # ● 取得控制物件
  724.   #--------------------------------------------------------------------------
  725.   def control
  726.     $game_system.stand.left
  727.   end
  728.   #--------------------------------------------------------------------------
  729.   # ● 重置位置
  730.   #--------------------------------------------------------------------------
  731.   def reset_position
  732.     return unless self.bitmap
  733.     super
  734.     self.x = self.width * -0.5
  735.   end
  736.   #--------------------------------------------------------------------------
  737.   # ● 取得已飛入的位置
  738.   #--------------------------------------------------------------------------
  739.   def slided_in_pos
  740.     pos = super
  741.     pos[0] = 0 # x座標為0
  742.     slide_in_pos_adjust(pos)
  743.   end
  744.   #--------------------------------------------------------------------------
  745.   # ● 已飛入位置調整
  746.   #--------------------------------------------------------------------------
  747.   def slide_in_pos_adjust(pos)
  748.     # 限制不過半
  749.     if pos[0] + self.width > 320
  750.       pos[0] = 320 - self.width
  751.     end
  752.     pos
  753.   end
  754.   #--------------------------------------------------------------------------
  755.   # ● 取得已飛出的位置
  756.   #--------------------------------------------------------------------------
  757.   def slided_out_pos
  758.     pos = super
  759.     pos[0] = -0.5 * self.width # x座標為負的一半寬度
  760.     pos
  761.   end

  762. end
  763. end


  764. #encoding:utf-8
  765. #==============================================================================
  766. # ■ Lctseng::Sprite_RightStand
  767. #------------------------------------------------------------------------------
  768. #     右方立繪精靈
  769. #==============================================================================
  770. module Lctseng
  771. class Sprite_RightStand < Sprite_Stand
  772.   #--------------------------------------------------------------------------
  773.   # ● 取得控制物件
  774.   #--------------------------------------------------------------------------
  775.   def control
  776.     $game_system.stand.right
  777.   end
  778.   #--------------------------------------------------------------------------
  779.   # ● 重置位置
  780.   #--------------------------------------------------------------------------
  781.   def reset_position
  782.     return unless self.bitmap
  783.     super
  784.     self.x = Graphics.width - self.width * 0.5
  785.   end
  786.   #--------------------------------------------------------------------------
  787.   # ● 取得已飛入的位置
  788.   #--------------------------------------------------------------------------
  789.   def slided_in_pos
  790.     pos = super
  791.     pos[0] = Graphics.width - self.width
  792.     slide_in_pos_adjust(pos)
  793.   end
  794.   #--------------------------------------------------------------------------
  795.   # ● 已飛入位置調整
  796.   #--------------------------------------------------------------------------
  797.   def slide_in_pos_adjust(pos)
  798.     # 限制不過半
  799.     if pos[0] < 320
  800.       pos[0] = 320
  801.     end
  802.     pos
  803.   end
  804.   #--------------------------------------------------------------------------
  805.   # ● 取得已飛出的位置
  806.   #--------------------------------------------------------------------------
  807.   def slided_out_pos
  808.     pos = super
  809.     pos[0] = Graphics.width - self.width * 0.5
  810.     pos
  811.   end
  812. end
  813. end

  814. #encoding:utf-8
  815. #==============================================================================
  816. # ■ Scene_Base
  817. #------------------------------------------------------------------------------
  818. #  游戲中所有 Scene 類(場景類)的父類
  819. #==============================================================================

  820. class Scene_Base
  821.   #--------------------------------------------------------------------------
  822.   # ● 重新定義
  823.   #--------------------------------------------------------------------------
  824.   unless $@
  825.     alias lctseng_stand_start start
  826.     alias lctseng_stand_update_basic update_basic
  827.     alias lctseng_stand_terminate terminate
  828.   end
  829.   #--------------------------------------------------------------------------
  830.   # ● 開始處理 【重新定義】
  831.   #--------------------------------------------------------------------------
  832.   def start
  833.     lctseng_stand_start
  834.     #create_stand_viewport
  835.     create_stand_spriteset
  836.   end
  837.   #--------------------------------------------------------------------------
  838.   # ● 產生立繪顯示端口
  839.   #--------------------------------------------------------------------------
  840.   def create_stand_viewport
  841.     @viewport_stand = Viewport.new
  842.     @viewport_stand.z = 100
  843.   end
  844.   #--------------------------------------------------------------------------
  845.   # ● 產生立繪精靈
  846.   #--------------------------------------------------------------------------
  847.   def create_stand_spriteset
  848.     # 修改不使用顯示端口,以便控制Z座標
  849.     @stand_spriteset = Lctseng::Spriteset_Stand.new(nil)
  850.   end
  851.   #--------------------------------------------------------------------------
  852.   # ● 更新畫面(基礎)【重新定義】
  853.   #--------------------------------------------------------------------------
  854.   def update_basic
  855.     lctseng_stand_update_basic
  856.     update_stand_spriteset
  857.   end
  858.   #--------------------------------------------------------------------------
  859.   # ● 更新立繪精靈
  860.   #--------------------------------------------------------------------------
  861.   def update_stand_spriteset
  862.     @stand_spriteset.update
  863.   end
  864.   #--------------------------------------------------------------------------
  865.   # ● 結束處理【重新定義】
  866.   #--------------------------------------------------------------------------
  867.   def terminate
  868.     stand_terminate
  869.     lctseng_stand_terminate
  870.     dispose_stand_spriteset
  871.     #dispose_stand_viewport
  872.   end
  873.   #--------------------------------------------------------------------------
  874.   # ● 釋放立繪精靈
  875.   #--------------------------------------------------------------------------
  876.   def dispose_stand_spriteset
  877.     @stand_spriteset.dispose
  878.   end
  879.   #--------------------------------------------------------------------------
  880.   # ● 釋放立繪顯示端口
  881.   #--------------------------------------------------------------------------
  882.   def dispose_stand_viewport
  883.     @viewport_stand.dispose
  884.   end
  885.   #--------------------------------------------------------------------------
  886.   # ● 立繪結束處理
  887.   #--------------------------------------------------------------------------
  888.   def stand_terminate
  889.     @stand_spriteset.terminate
  890.     while @stand_spriteset.terminating?
  891.       @stand_spriteset.terminate_countdown
  892.       puts "結束前處理"
  893.       @stand_spriteset.update
  894.       Graphics.update
  895.     end
  896.   end

  897. end

  898. #encoding:utf-8
  899. #==============================================================================
  900. # ■ Scene_Map
  901. #------------------------------------------------------------------------------
  902. #  地圖畫面
  903. #==============================================================================

  904. class Scene_Map < Scene_Base
  905.   #--------------------------------------------------------------------------
  906.   # ● 重新定義
  907.   #--------------------------------------------------------------------------
  908.   unless $@
  909.     alias lctseng_stand_pre_transfer pre_transfer
  910.   end

  911.   #--------------------------------------------------------------------------
  912.   # ● 場所移動前的處理【重新定義】
  913.   #--------------------------------------------------------------------------
  914.   def pre_transfer
  915.     puts "場所移動處理"
  916.     stand_terminate
  917.     lctseng_stand_pre_transfer
  918.   end
  919. end
复制代码


需要配合使用的图像精灵强化脚本(前置脚本)
  1. #encoding:utf-8

  2. =begin
  3. *******************************************************************************************

  4.    * 圖像精靈強化 *

  5.                        for RGSS3

  6.         Ver 1.10   2014.12.02

  7.    原作者:魂(Lctseng),巴哈姆特論壇ID:play123
  8.    

  9.    轉載請保留此標籤

  10.    個人小屋連結:http://home.gamer.com.tw/homeindex.php?owner=play123

  11.    主要功能:
  12.                        一、大部分Lctseng發布的圖像有關腳本都需要有此腳本作為前置腳本
  13.                        

  14.    更新紀錄:
  15.     Ver 1.00 :
  16.     日期:2014.09.24
  17.     摘要:■、最初版本

  18.     Ver 1.10 :
  19.     日期:2014.12.02
  20.     摘要:■、更新Sprite_Drawer,新增param_change_color
  21.    
  22.     撰寫摘要:一、此腳本修改或重新定義以下類別:
  23.                            ■ Sprite
  24.                           
  25.                         二、此腳本新定義以下類別和模組:
  26.                            ■ SpriteDrawer
  27.                            ■ SpriteFader
  28.                            ■ SpriteSlider
  29.                            ■ SpriteSensor
  30.                            ■ SpriteZoomer
  31.                           

  32. *******************************************************************************************
  33. =end


  34. #*******************************************************************************************
  35. #
  36. #   請勿修改從這裡以下的程式碼,除非你知道你在做什麼!
  37. #   DO NOT MODIFY UNLESS YOU KNOW WHAT TO DO !
  38. #
  39. #*******************************************************************************************

  40. #--------------------------------------------------------------------------
  41. # ★ 紀錄腳本資訊
  42. #--------------------------------------------------------------------------
  43. if !$lctseng_scripts  
  44.   $lctseng_scripts = {}
  45. end


  46. $lctseng_scripts[:sprite_ex] = "1.00"

  47. puts "載入腳本:Lctseng - 圖像精靈強化,版本:#{$lctseng_scripts[:sprite_ex]}"



  48. #encoding:utf-8
  49. #==============================================================================
  50. # ■ Sprite
  51. #------------------------------------------------------------------------------
  52. #  精靈。
  53. #==============================================================================

  54. class  Sprite
  55.   #--------------------------------------------------------------------------
  56.   # ● 執行精靈居中
  57.   #--------------------------------------------------------------------------
  58.   def center_sprite
  59.     center_origin
  60.     self.x = Graphics.width / 2
  61.     self.y = Graphics.height / 2
  62.   end
  63.   #--------------------------------------------------------------------------
  64.   # ● 執行精靈原點居中
  65.   #--------------------------------------------------------------------------
  66.   def center_origin
  67.     if self.bitmap
  68.       self.ox = self.bitmap.width / 2
  69.       self.oy = self.bitmap.height / 2
  70.     end
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● 滑鼠是否在精靈內?
  74.   #--------------------------------------------------------------------------
  75.   def mouse_in_area?
  76.     if self.bitmap
  77.       Mouse.area?(self.x - self.ox,self.y - self.oy,self.bitmap.width,self.bitmap.height)
  78.     else
  79.       false
  80.     end
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● 當前位置
  84.   #--------------------------------------------------------------------------
  85.   def current_pos
  86.     [self.x , self.y]
  87.   end
  88.   #--------------------------------------------------------------------------
  89.   # ● 設定位置
  90.   #--------------------------------------------------------------------------
  91.   def set_pos(pos)
  92.     self.x = pos[0]
  93.     self.y = pos[1]
  94.   end
  95. end


  96. #encoding:utf-8
  97. #==============================================================================
  98. # ■ SpriteDrawer
  99. #------------------------------------------------------------------------------
  100. #  讓精靈可以進行類似Window那樣繪製文字的模組
  101. # UPDATE:14008062248 Ver 1.3
  102. #==============================================================================
  103. module SpriteDrawer
  104.   #--------------------------------------------------------------------------
  105.   # ● 取得視窗外框位圖
  106.   #--------------------------------------------------------------------------
  107.   def windowskin
  108.     Cache.system("Window")
  109.   end
  110.   #--------------------------------------------------------------------------
  111.   # ● 獲取內容尺寸
  112.   #--------------------------------------------------------------------------
  113.   def text_size(str)
  114.     self.bitmap.text_size(str)
  115.   end
  116.   #--------------------------------------------------------------------------
  117.   # ● 獲取項目的繪制矩形
  118.   #--------------------------------------------------------------------------
  119.   def item_rect(index)
  120.     rect = Rect.new
  121.     rect.width = item_width
  122.     rect.height = item_height
  123.     rect.x = index % col_max * (item_width + spacing)
  124.     rect.y = index / col_max * item_height
  125.     rect
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● 獲取項目寬度
  129.   #--------------------------------------------------------------------------
  130.   def item_width
  131.     192
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 獲取項目高度
  135.   #--------------------------------------------------------------------------
  136.   def item_height
  137.     line_height
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # ● 獲取列數
  141.   #--------------------------------------------------------------------------
  142.   def col_max
  143.     return 1
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # ● 獲取行間距的寬度
  147.   #--------------------------------------------------------------------------
  148.   def spacing
  149.     return 32
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● 獲取文字顏色
  153.   #     n : 文字顏色編號(0..31)
  154.   #--------------------------------------------------------------------------
  155.   def text_color(n)
  156.     windowskin.get_pixel(64 + (n % 8) * 8, 96 + (n / 8) * 8)
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # ● 繪製文字
  160.   #--------------------------------------------------------------------------
  161.   def draw_text(*args,&block)
  162.     self.bitmap.draw_text(*args,&block)
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 繪制圖標
  166.   #     enabled : 有效的標志。false 的時候使用半透明效果繪制
  167.   #--------------------------------------------------------------------------
  168.   def draw_icon(icon_index, x, y, enabled = true)
  169.     temp_bitmap = Cache.system("Iconset")
  170.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  171.     self.bitmap.blt(x, y, temp_bitmap, rect, enabled ? 255 : translucent_alpha)
  172.   end
  173.   #--------------------------------------------------------------------------
  174.   # ● 繪制圖標,指定目標矩形
  175.   #     enabled : 有效的標志。false 的時候使用半透明效果繪制
  176.   #--------------------------------------------------------------------------
  177.   def draw_icon_with_rect(icon_index,  target_rect ,enabled = true)
  178.     temp_bitmap = Cache.system("Iconset")
  179.     rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  180.     self.bitmap.stretch_blt(target_rect, temp_bitmap, rect, enabled ? 255 : translucent_alpha)
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # ● 獲取半透明繪制用的透明度
  184.   #--------------------------------------------------------------------------
  185.   def translucent_alpha
  186.     return 160
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # ● 繪制物品名稱
  190.   #     enabled : 有效的標志。false 的時候使用半透明效果繪制
  191.   #--------------------------------------------------------------------------
  192.   def draw_item_name(item, x, y, enabled = true, width = 172)
  193.     return unless item
  194.     draw_icon(item.icon_index, x, y, enabled)
  195.     change_color(normal_color, enabled)
  196.     draw_text(x + 24, y, width, line_height, item.name)
  197.   end
  198.   #--------------------------------------------------------------------------
  199.   # ● 繪制物品細節名稱
  200.   #--------------------------------------------------------------------------
  201.   def draw_detail_name(item, x, y, enabled = true, width = 172)
  202.     return unless item.is_a?(Game_Equip_Details)
  203.     color = item.fmts[1]
  204.     match_item = item.get_match
  205.     return unless match_item
  206.     item_name = sprintf(item.fmts[0],match_item.name)
  207.     item_icon_index = match_item.icon_index
  208.     if enabled
  209.       change_color(text_color(color),true)
  210.     else
  211.       change_color(normal_color, false)
  212.     end
  213.     draw_icon(item_icon_index, x, y, enabled)
  214.     draw_text(x + 24, y, width, line_height, item_name)
  215.   end
  216.   #--------------------------------------------------------------------------
  217.   # ● 繪制名字
  218.   #--------------------------------------------------------------------------
  219.   def draw_actor_name(actor, x, y, width = 112,align = 0)
  220.     # change_color(hp_color(actor))
  221.     draw_text(x, y, width, line_height, actor.name,align)
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # ● 更改內容繪制顏色
  225.   #     enabled : 有效的標志。false 的時候使用半透明效果繪制
  226.   #--------------------------------------------------------------------------
  227.   def change_color(color, enabled = true)
  228.     self.bitmap.font.color.set(color)
  229.     self.bitmap.font.color.alpha = translucent_alpha unless enabled
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ● 更改字型
  233.   #--------------------------------------------------------------------------
  234.   def change_font(font)
  235.     self.bitmap.font = font if self.bitmap
  236.   end
  237.   #--------------------------------------------------------------------------
  238.   # ● 獲取行高
  239.   #--------------------------------------------------------------------------
  240.   def line_height
  241.     return 24
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● 更換字體大小
  245.   #--------------------------------------------------------------------------
  246.   def change_font_size(sz)
  247.     self.bitmap.font.size = sz
  248.   end
  249.   #--------------------------------------------------------------------------
  250.   # ● 繪製數值條內容
  251.   # 給定:座標、最大值、當前值、圖檔名稱
  252.   #--------------------------------------------------------------------------
  253.   def draw_gauge_content(dx,dy,current,max,filename)
  254.     bitmap = Cache.battle(filename)
  255.     rect = bitmap.rect.clone
  256.     if max <= 0
  257.       rate = 0
  258.     else
  259.       rate = (current.to_f/max)
  260.     end
  261.     rect.width = (rect.width * rate + 0.5).round
  262.     self.bitmap.blt(dx,dy,bitmap,rect)
  263.     change_color(normal_color)
  264.     draw_text(dx,dy-3,bitmap.rect.width - 3,16,sprintf("%d / %d",current,max),2)
  265.   end
  266.   #--------------------------------------------------------------------------
  267.   # ● 繪製子彈資訊
  268.   #--------------------------------------------------------------------------
  269.   def draw_bullet_info_by_detail(detail,x,y,dw = 115 , dh = 18)
  270.     # 字型大小設置:子彈型
  271.     change_font(Lctseng.bullet_font)
  272.    
  273.     item = nil
  274.     if detail
  275.       item = detail.get_match
  276.     end
  277.     if item && item.need_bullet?
  278.       ammo = detail.ammo
  279.       bullet_item = ammo.item
  280.       if detail.has_loaded_bullet_id? && bullet_item
  281.         draw_bullet(ammo,x,y,dw,dh)
  282.       else
  283.         change_color(system_color)
  284.         draw_text(x,y,dw,dh,"無裝備任何子彈")
  285.       end
  286.     else
  287.       # 子彈不存在或不需要子彈
  288.       change_color(system_color)
  289.       draw_text(x,y,dw,dh,"無須使用子彈")
  290.     end
  291.    
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # ● 繪製子彈
  295.   #--------------------------------------------------------------------------
  296.   def draw_bullet(ammo,x,y,total_dw,dh)
  297.     amount_dw = 40
  298.     dw = total_dw - amount_dw
  299.     item = ammo.item
  300.     bullet = ammo.bullet_obj
  301.     # 繪製圖標
  302.     draw_icon_with_rect(item.icon_index,Rect.new(x,y,dh,dh))
  303.     # 基準座標位移
  304.     diff = (dh + 1)
  305.     x += diff
  306.     dw -= diff
  307.     # 繪製文字
  308.    
  309.     change_color(text_color(6))
  310.     name = bullet.display_name
  311.     text_w = text_size(name).width
  312.     #contents.fill_rect(Rect.new(x,y,dw,dh),Color.new(255,0,0))
  313.     draw_text(x,y,dw,dh,name)
  314.    
  315.     # 基準座標位移
  316.     x += ( text_w + 1 )
  317.     # 繪製數量
  318.     amount = ammo.bullet_remain
  319.     if amount > 0
  320.       change_color(Color.new(0,255,0))
  321.     else
  322.       change_color(Color.new(255,0,0))
  323.     end
  324.     str = sprintf("(%d)",amount)
  325.     #contents.fill_rect(Rect.new(x,y,amount_dw,dh),Color.new(255,255,0))
  326.     draw_text(x,y,amount_dw,dh,str)
  327.    
  328.   end
  329.   #--------------------------------------------------------------------------
  330.   # ● 獲取能力值變化的繪制色
  331.   #--------------------------------------------------------------------------
  332.   def param_change_color(change)
  333.     return power_up_color   if change > 0
  334.     return power_down_color if change < 0
  335.     return normal_color
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● 獲取各種文字顏色
  339.   #--------------------------------------------------------------------------
  340.   def normal_color;      text_color(0);   end;    # 普通
  341.   def system_color;      text_color(16);  end;    # 系統
  342.   def crisis_color;      text_color(17);  end;    # 危險
  343.   def knockout_color;    text_color(18);  end;    # 無法戰斗
  344.   def gauge_back_color;  text_color(19);  end;    # 值槽背景
  345.   def hp_gauge_color1;   text_color(20);  end;    # HP 值槽 1
  346.   def hp_gauge_color2;   text_color(21);  end;    # HP 值槽 2
  347.   def mp_gauge_color1;   text_color(22);  end;    # MP 值槽 1
  348.   def mp_gauge_color2;   text_color(23);  end;    # MP 值槽 2
  349.   def mp_cost_color;     text_color(23);  end;    # 消費 TP
  350.   def power_up_color;    text_color(24);  end;    # 能力值提升(更換裝備時)
  351.   def power_down_color;  text_color(25);  end;    # 能力值降低(更換裝備時)
  352.   def tp_gauge_color1;   text_color(28);  end;    # TP 值槽 1
  353.   def tp_gauge_color2;   text_color(29);  end;    # TP 值槽 2
  354.   def tp_cost_color;     text_color(29);  end;    # 消費 TP
  355.   end
  356.   
  357.   
  358.   
  359.   #encoding:utf-8
  360. #==============================================================================
  361. # ■ SpriteFader
  362. #------------------------------------------------------------------------------
  363. #  讓精靈可以進行淡出淡入所需的原件
  364. #==============================================================================
  365. module SpriteFader
  366.   #--------------------------------------------------------------------------
  367.   # ● 初始化淡入淡出模組
  368.   #--------------------------------------------------------------------------
  369.   def fader_init
  370.     @fade_count = 0
  371.     @fade_to = 0
  372.     @fade_real_opacity = 0.0
  373.     @fade_speed = 0.0
  374.     @fade_post_handler = nil
  375.     @fade_init = true
  376.     @fade_processing = false
  377.   end
  378.   #--------------------------------------------------------------------------
  379.   # ● 設置淡入淡出 (設定目的透明度與時間)
  380.   #--------------------------------------------------------------------------
  381.   def fader_set_fade(to,time)
  382.     @fade_count = time
  383.     @fade_to = to.to_f
  384.     @fade_real_opacity = self.opacity.to_f
  385.     @fade_speed = ( @fade_to - @fade_real_opacity ) / @fade_count + 0.001
  386.     @fade_processing = true
  387.   end
  388.   #--------------------------------------------------------------------------
  389.   # ● 更新淡入淡出
  390.   #--------------------------------------------------------------------------
  391.   def fader_update
  392.     return if !@fade_init
  393.     if @fade_count > 0
  394.       @fade_count -= 1
  395.       self.opacity = @fade_real_opacity += @fade_speed
  396.     else
  397.       if @fade_processing
  398.         @fade_processing = false
  399.         fader_post_fade
  400.       end
  401.     end
  402.   end
  403.   #--------------------------------------------------------------------------
  404.   # ● 是否淡入淡出?
  405.   #--------------------------------------------------------------------------
  406.   def fader_fading?
  407.     @fade_init && @fade_count > 0
  408.   end
  409.   #--------------------------------------------------------------------------
  410.   # ● 設置淡入淡出結束後處理
  411.   #--------------------------------------------------------------------------
  412.   def fader_set_post_handler(handler)
  413.     @fade_post_handler = handler
  414.   end
  415.   #--------------------------------------------------------------------------
  416.   # ● 呼叫淡入淡出結束後處理
  417.   #--------------------------------------------------------------------------
  418.   def fader_post_fade
  419.     if @fade_post_handler
  420.       @fade_post_handler.call
  421.     end
  422.   end
  423.   #--------------------------------------------------------------------------
  424.   # ● 清除呼叫淡入淡出結束後的處理程序
  425.   #--------------------------------------------------------------------------
  426.   def fader_clear_handler
  427.     @fade_post_handler = nil
  428.   end
  429. end


  430. #encoding:utf-8
  431. #==============================================================================
  432. # ■ SpriteSlider
  433. #------------------------------------------------------------------------------
  434. #  讓精靈可以進行移動所需的原件
  435. #  UPDATE:1407091114
  436. #==============================================================================
  437. module SpriteSlider
  438.   #--------------------------------------------------------------------------
  439.   # ● 初始化移動模組
  440.   #--------------------------------------------------------------------------
  441.   def slider_init
  442.     @slide_count = 0
  443.     @slide_real_pos = [0.0,0.0]
  444.     @slide_from = [0,0]
  445.     @slide_to = [0,0]
  446.     @slide_speed = [0.0,0.0]
  447.     @slide_init = true
  448.     @slide_post_handler = nil
  449.     @slide_processing = false
  450.   end
  451.   #--------------------------------------------------------------------------
  452.   # ● 設置移動
  453.   #--------------------------------------------------------------------------
  454.   def slider_set_move(from,to,time)
  455.     @slide_count = time
  456.     @slide_from = from.collect {|i| i.to_f}
  457.     @slide_to = to.collect {|i| i.to_f}
  458.     @slide_real_pos = @slide_from.clone
  459.     # 設置速度
  460.     2.times do |i|
  461.       @slide_speed[i] = (@slide_to[i] - @slide_from[i]) / @slide_count
  462.     end
  463.     @slide_processing = true
  464.    
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # ● 更新移動
  468.   #--------------------------------------------------------------------------
  469.   def slider_update
  470.     return if !@slide_init
  471.     if @slide_count > 0
  472.       @slide_count -= 1
  473.       2.times do |i|
  474.         @slide_real_pos[i] = @slide_real_pos[i] + @slide_speed[i]
  475.       end
  476.       self.x = @slide_real_pos[0]
  477.       self.y = @slide_real_pos[1]
  478.     else
  479.       if @slide_processing
  480.         slider_adjust_pos
  481.         @slide_processing = false
  482.         slider_post_method
  483.       end
  484.     end
  485.   end
  486.   #--------------------------------------------------------------------------
  487.   # ● 修正最後位置
  488.   #--------------------------------------------------------------------------
  489.   def slider_adjust_pos
  490.     self.x , self.y = @slide_to
  491.   end
  492.   #--------------------------------------------------------------------------
  493.   # ● 是否移動動?
  494.   #--------------------------------------------------------------------------
  495.   def slider_sliding?
  496.     @slide_init && @slide_count > 0
  497.   end
  498.   #--------------------------------------------------------------------------
  499.   # ● 呼叫移動後的方法
  500.   #--------------------------------------------------------------------------
  501.   def slider_post_method
  502.     if @slide_post_handler
  503.       @slide_post_handler.call
  504.     end
  505.   end
  506.   #--------------------------------------------------------------------------
  507.   # ● 設置移動結束後處理
  508.   #--------------------------------------------------------------------------
  509.   def slider_set_post_handler(handler)
  510.     @slide_post_handler = handler
  511.   end
  512.   #--------------------------------------------------------------------------
  513.   # ● 清除呼叫移動出結束後的處理程序
  514.   #--------------------------------------------------------------------------
  515.   def slider_clear_handler
  516.     @slide_post_handler = nil
  517.   end
  518.   #--------------------------------------------------------------------------
  519.   # ● 清除呼叫移動出結束後的處理程序
  520.   #--------------------------------------------------------------------------
  521.   def slider_clear_post_handler
  522.     @slide_post_handler = nil
  523.   end
  524. end

  525. #encoding:utf-8
  526. #==============================================================================
  527. # ■ SpriteSensor
  528. # 更新:1408061703 Ver 1.1
  529. #------------------------------------------------------------------------------
  530. #  讓精靈可以感應滑鼠放置所需的原件
  531. #==============================================================================
  532. module SpriteSensor
  533.   #--------------------------------------------------------------------------
  534.   # ● 初始化感應模組
  535.   #--------------------------------------------------------------------------
  536.   def sensor_init
  537.     @sensor_init = true
  538.     @sensor_hover_handler = nil
  539.     @sensor_input_handler = nil
  540.     @sensor_set_hover = false
  541.     @sensor_set_input = false
  542.     @active = false
  543.   end
  544.   #--------------------------------------------------------------------------
  545.   # ● 其他啟動條件
  546.   #--------------------------------------------------------------------------
  547.   def sensor_other_active_condition
  548.     true
  549.   end
  550.   #--------------------------------------------------------------------------
  551.   # ● 啟用感應器
  552.   #--------------------------------------------------------------------------
  553.   def sensor_activate
  554.     @active = true
  555.   end
  556.   #--------------------------------------------------------------------------
  557.   # ● 停用感應器
  558.   #--------------------------------------------------------------------------
  559.   def sensor_deactivate
  560.     @active = false
  561.   end
  562.   #--------------------------------------------------------------------------
  563.   # ● 設置懸浮感應處理程序
  564.   #--------------------------------------------------------------------------
  565.   def sensor_set_sense_hover(handler)
  566.     @sensor_set_hover = true
  567.     @sensor_hover_handler = handler
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # ● 設置按鈕感應處理程序
  571.   #--------------------------------------------------------------------------
  572.   def sensor_set_sense_input(handler)
  573.     @sensor_set_input = true
  574.     @sensor_input_handler = handler
  575.   end
  576.   #--------------------------------------------------------------------------
  577.   # ● 滑鼠是否在精靈內?
  578.   #--------------------------------------------------------------------------
  579.   def sensor_mouse_in_area?
  580.     if self.bitmap
  581.       Mouse.area?(self.x - self.ox,self.y - self.oy,self.bitmap.width,self.bitmap.height)
  582.     else
  583.       false
  584.     end
  585.   end
  586.   #--------------------------------------------------------------------------
  587.   # ● 呼叫感應器的檢查方法
  588.   #--------------------------------------------------------------------------
  589.   def sensor_call_input
  590.     if Input.trigger?(:C)
  591.       @sensor_input_handler.call(:C)
  592.     end
  593.   end
  594.   #--------------------------------------------------------------------------
  595.   # ● 滑鼠是否在精靈內?包含啟動測試
  596.   #--------------------------------------------------------------------------
  597.   def sensor_mouse_in_area_safe?
  598.     @sensor_init  && @active && sensor_mouse_in_area?
  599.   end
  600.   #--------------------------------------------------------------------------
  601.   # ● 更新感應
  602.   #--------------------------------------------------------------------------
  603.   def sensor_update
  604.     return if !@sensor_init
  605.     return if !@active
  606.     return if !sensor_other_active_condition
  607.     if @sensor_hover_handler
  608.       if sensor_mouse_in_area?
  609.         if @sensor_set_hover && @sensor_hover_handler
  610.           @sensor_hover_handler.call(true)
  611.         end
  612.         if @sensor_set_input && @sensor_input_handler
  613.           sensor_call_input
  614.         end
  615.       else
  616.         if @sensor_set_hover && @sensor_hover_handler
  617.           @sensor_hover_handler.call(false)
  618.         end
  619.       end
  620.     end
  621.   end
  622. end

  623. #encoding:utf-8
  624. #==============================================================================
  625. # ■ SpriteZoomer
  626. #------------------------------------------------------------------------------
  627. #  讓精靈可以進行放大縮小所需的原件,內部實例變數以 "_" 開頭,公開方法以"zoomer"開頭
  628. #==============================================================================
  629. module SpriteZoomer
  630.   #--------------------------------------------------------------------------
  631.   # ● 初始化縮放模組
  632.   #--------------------------------------------------------------------------
  633.   def zoomer_init
  634.     @_zoom_count = 0
  635.     @_zoom_from = [0.0,0.0]
  636.     @_zoom_to = [0.0,0.0]
  637.     @_zoom_speed = [0.0,0.0]
  638.     @_zoom_init = true
  639.     @_zoom_post_handler = nil
  640.     @_zoom_processing = false
  641.   end
  642.   #--------------------------------------------------------------------------
  643.   # ● 設置縮放
  644.   #--------------------------------------------------------------------------
  645.   def zoomer_set_effect(from,to,time)
  646.     self.zoom_x , self.zoom_y = from
  647.     @_zoom_count = time
  648.     @_zoom_from = from
  649.     @_zoom_to = to
  650.     # 設置速度
  651.     2.times do |i|
  652.       @_zoom_speed[i] = (@_zoom_to[i] - @_zoom_from[i]) / @_zoom_count
  653.     end
  654.     @_zoom_processing = true
  655.    
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # ● 更新縮放
  659.   #--------------------------------------------------------------------------
  660.   def zoomer_update
  661.     return if !@_zoom_init
  662.     if @_zoom_count > 0
  663.       @_zoom_count -= 1
  664.       self.zoom_x += @_zoom_speed[0]
  665.       self.zoom_y += @_zoom_speed[1]
  666.     else
  667.       if @_zoom_processing
  668.         @_zoom_processing = false
  669.         zoomer_post_method
  670.       end
  671.     end
  672.   end
  673.   #--------------------------------------------------------------------------
  674.   # ● 是否效果中?
  675.   #--------------------------------------------------------------------------
  676.   def zoomer_effect?
  677.     @_zoom_init && @_zoom_count > 0
  678.   end
  679.   #--------------------------------------------------------------------------
  680.   # ● 呼叫縮放後的方法
  681.   #--------------------------------------------------------------------------
  682.   def zoomer_post_method
  683.     if @_zoom_post_handler
  684.       @_zoom_post_handler.call
  685.     end
  686.   end
  687.   #--------------------------------------------------------------------------
  688.   # ● 設置縮放結束後處理
  689.   #--------------------------------------------------------------------------
  690.   def zoomer_set_post_handler(handler)
  691.     @_zoom_post_handler = handler
  692.   end
  693.   #--------------------------------------------------------------------------
  694.   # ● 清除呼叫縮放出結束後的處理程序
  695.   #--------------------------------------------------------------------------
  696.   def zoomer_clear_handler
  697.     @_zoom_post_handler = nil
  698.   end
  699. end
复制代码


作者: cinderelmini    时间: 2016-11-2 13:29
Kim_巧克力控 发表于 2016-11-1 21:23
需要配合使用的图像精灵强化脚本(前置脚本)


2K+行的立绘代码………………………………

绕来绕去已经看不明白了……
先试试看下面这种暴力排错的办法吧…………
在出错的那个方法最开始的地方排除一下意外情况…………
  1. #--------------------------------------------------------------------------
  2.   # ● 立繪結束處理
  3.   #--------------------------------------------------------------------------
  4.   def stand_terminate
  5.     return unless @stand_spriteset    # 排除不存在的情况
  6.     return if @stand_spriteset.disposed?  # 排除已经释放的情况
  7.     @stand_spriteset.terminate
  8.     while @stand_spriteset.terminating?
  9.       @stand_spriteset.terminate_countdown
  10.       puts "結束前處理"
  11.       @stand_spriteset.update
  12.       Graphics.update
  13.     end
  14.   end
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1