发现问题!如果制作了新的冒险书,进去后打开菜单按返回标题画面,Scene_Title 就会变回默认! |
- -收藏研究先 |
本帖最后由 紫苏 于 2010-10-3 09:23 编辑 这个的确是设计模式的的问题。以前 6R 就有高手提出过,根据 UI 设计原理,我们应该把这些命令当做按钮控件,触发按钮时调用与控件相关联的回调函数,和六祈这里使用的思想不谋而合,只不过该高手用的是 Proc。 关于绑定,Method 对象在创建时会创建对象分配内存并绑定到其拥有者对象,send 的话少了这些过程,因为它触发的是本身就存在于对象虚表中的成员。 一个简单的测试:
Ruby supports two forms of objectified methods. Class Method is used to represent methods that are associated with a particular object: these method objects are bound to that object. Bound method objects for an object can be created using Object#method. Ruby also supports unbound methods, which are method objects that are not associated with a particular object. These can be created either by calling unbind on a bound method object or by calling Module#instance_method. Unbound methods can be called only after they are bound to an object. That object must be a kind_of? the method’s original class. 所以有时也可以使用 UnboundMethod 来最大化灵活性(可以随随意绑定到任何对象),同时也保证了不因为绑定而降低性能。 Ruby中不会发生,也不存在function.fun这种调用方式,只有对象才可以接收消息,而def的方法显然还不是一个对象 这个其实要做到也可以的,只不过会让读者觉得很困惑。Ruby 的一切动态绑定都和上下文有关,只要接受者的上下文能够响应请求的符号,就能调用到预期的方法:
换一个例子来看:
|
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2025-4-18 06:26
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.