Project1

标题: 退出提示确认脚本,在RTAB战斗中退出会报错。 [打印本页]

作者: 天使喝可乐    时间: 2011-8-31 21:43
标题: 退出提示确认脚本,在RTAB战斗中退出会报错。
我用的RTAB战斗系统,用上退出提示脚本(点X提示[确认][取消])
平时没问题 但是战斗中点退出→确认 后会报错 虽然这样也退出了……但是很影响美观 求改下= =  谢谢~
如果改的不是退出提示脚本 麻烦把改的地方标出来 谢谢拉!
范例:(范例中自带脚本)
DIRO框架.rar (1.23 MB, 下载次数: 5)
报错图:


错误脚本为RTAB战斗主脚本 那段是这样的:
  1.   def screen_z
  2.     return true_y + @fly
  3.   end
  4.   #--------------------------------------------------------------------------
  5.   # バトル画面 拡大率の取得
  6.   #--------------------------------------------------------------------------
  7.   def zoom
  8. #●●●●● 下面这行就是报错行 3422:
  9.     return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
  10.                           (true_y + @fly) / 320 + $scene.zoom_rate[0]
  11.   end
  12.   #--------------------------------------------------------------------------
  13.   # 攻撃用、バトル画面 X 座標の取得
  14.   #--------------------------------------------------------------------------
  15.   def attack_x(z)
  16.     return (320 - true_x) * z * 0.75
  17.   end
复制代码
退出提示脚本:
  1. if true#true为使用,false为不使用
  2. def exit(i=0)
  3. name="仙境之梦退出确认"#提示标题,可不填
  4. $scene = nil if options("是否要退出游戏?",name)
  5. end
  6. end
  7. def options(text,name="")
  8. @ask1 = [text,name]
  9. @ctext = Array.new
  10. @m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
  11. @w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
  12. @msgbox = Win32API.new('user32', 'MessageBox', %w(p p p i), 'i')
  13. @wsm = Proc.new{|i|
  14.         len = @m2w.call(65001, 0, i, -1, nil, 0)
  15.         buf = "\0\0" * len
  16.         @m2w.call(65001, 0, i, -1, buf, buf.size/2)
  17.         len = @w2m.call(0, 0, buf, -1, nil, 0, nil, nil)
  18.         @ctext.push "\0" * len
  19.         @w2m.call(0, 0, buf, -1, @ctext.last, @ctext.last.size, nil, nil)
  20.         }
  21. [@ask1].flatten.each{|i| @wsm.call(i)}
  22.   def self.warning
  23.     1.times{|j| j == 0 ?((yield @ctext[0], @ctext[1]) == 1 ? (return true) : (return false)):( return false)}
  24.   end
  25.   return self.warning{|a,b| @msgbox.call(0, a, b, 1) }
  26. end
复制代码
dsu_plus_rewardpost_czw
作者: Wind2010    时间: 2011-8-31 21:46
大概是在处理Scene的update时按退出-确定后$scene(场景)变为nil,但是update里依然有对于$scene的判断,所以会报错
解放方法:本人渣渣不知道XD
作者: darkscout3000    时间: 2011-8-31 22:11
我认为是在战斗场景的那个scene没有定义zoom_rate方法⋯⋯
因为地图的scene类和战斗场景不同⋯⋯而每次切换场景都会把$scene这个变量指向不同的类实例⋯⋯
所以⋯⋯

没空看代码,纯粹是猜测⋯⋯
作者: 天使喝可乐    时间: 2011-9-1 11:11
这个问题很冷吗= =囧
作者: 羞射了    时间: 2011-9-1 11:27
  #--------------------------------------------------------------------------
  # ● バトル画面 拡大率の取得
  #--------------------------------------------------------------------------
  def zoom
    if $scene != nil
    return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
                          (true_y + @fly) / 320 + $scene.zoom_rate[0]
      else
    return 1
    end
  end

这样先试试吧。




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