| 
 
| 赞 | 0 |  
| VIP | 8 |  
| 好人卡 | 27 |  
| 积分 | 65 |  
| 经验 | 41413 |  
| 最后登录 | 2012-10-21 |  
| 在线时间 | 833 小时 |  
 Lv4.逐梦者 弓箭手?剑兰 
	梦石0 星屑6539 在线时间833 小时注册时间2010-11-17帖子1140 | 
| 回复 苏小脉 的帖子 
 抱歉,我还是没跟上,这个和我们之前讨论的有什么联系?之前不是说过用您的办法后函数外给变量定义会出错么?(沉影dll鼠标会出现Sprite disposed)
 但是函数内给变量定义且没问题。看一下两个例子:
 
 复制代码# 函数外赋值(F12杯具)
$__f12_no_reeval.call if $__f12_no_reeval
module AAA
  @a = Sprite.new
  def self.a
    @a.x = 100
    p @a.x
  end
end
callcc { |$__f12_no_reeval| }
AAA.a     # 代表Scene_Base的update
如果是函数内赋值:
 
 复制代码# 函数内赋值(F12无问题, 但耗费逻辑时间)
$__f12_no_reeval.call if $__f12_no_reeval
module AAA
  def self.a
    @a = Sprite.new if @a.nil? or @a.disposed?
    @a.x = 100
    p @a.x
  end
end
callcc { |$__f12_no_reeval| }
AAA.a     # 代表Scene_Base的update
 不用啊,为什么?那篇文章里面给的例子就是在 Main 的开头设立了一个跳转点,我的意思是需要的话可以在不同的地方设立多个,这样可以控制 F12 之后哪段执行,哪段跳过。如果跳一次的话,就要将alias和函数外定义变量分开= =但是跳来跳去也挺乱的。
 但是这样(即有alias和函数外定义变量):
 
 复制代码#~ $__f12_no_reeval.call if $__f12_no_reeval
module Graphics
  @speed_update = method("update")
  @speed_lv = Sprite.new
  @speed_lv.x = 50
  def self.update
    a = @speed_lv.x
    @speed_update.call
  end
end
#~ callcc { |$__f12_no_reeval| }
Graphics.update      # 代表后置的场景操作
# 用callcc的时候会发生Sprite disposed
# 不用的时候会发生stack level too deep
而我说的将两者分开的做法是这样:
 
 复制代码$__f12_no_reeval.call if $__f12_no_reeval
# alias/函数 堆
module Graphics
  @speed_update = method("update")
  def self.update
    a = @speed_lv.x
    @speed_update.call
  end
end
callcc { |$__f12_no_reeval| }  # callcc
# 函数外赋值 堆
module Graphics
  @speed_lv = Sprite.new
  @speed_lv.x = 50
end
Graphics.update      # 代表后置的场景操作
我想您说的办法应该是这样:
 
 复制代码
$__f12_no_reeval.call if $__f12_no_reeval
module Graphics
  @speed_update = method("update")
  callcc { |$__f12_no_reeval| }    # callcc
  @speed_lv = Sprite.new
  @speed_lv.x = 50
  def self.update
    a = @speed_lv.x
    @speed_update.call
  end
end
Graphics.update      # 代表后置的场景操作
嗯~相信您会清楚我在说啥...
 
 | 
 |