| 
我实在是不知道去哪里问这个问题了=。=,所以还是来这里求助了,于是先上脚本=-=
x
加入我们,或者,欢迎回来。您需要 登录 才可以下载或查看,没有帐号?注册会员  
 #==============================================================================# Dynamic Proxy#==============================================================================module DynamicProxy_Mixin  def self.included(base)    base.extend(Proxy_Methods)  end   module Proxy_Methods    def add_new_proxy(*args)      class_eval %{        def proxy_methods_targets          #{args}        end         def method_missing(name,*args,&block)          proxy_methods_targets.each{|target| target.send(name,*args,&block)}        end       }     end  endend
#============================================================================== 
# Dynamic Proxy 
#============================================================================== 
module DynamicProxy_Mixin 
  def self.included(base) 
    base.extend(Proxy_Methods) 
  end 
  
  module Proxy_Methods 
    def add_new_proxy(*args) 
      class_eval %{ 
        def proxy_methods_targets 
          #{args} 
        end 
  
        def method_missing(name,*args,&block) 
          proxy_methods_targets.each{|target| target.send(name,*args,&block)} 
        end 
  
      } 
  
    end 
  end 
end 
 于是这个脚本的用处就是。。
 
 class ProxyTest  include DynamicProxy_Mixin   add_new_proxy @sprite  def initialize    @sprite=Sprite.new  end   end proxy=ProxyTest.newproxy.visible=false #其实是将sprite的visible设置为false
class ProxyTest 
  include DynamicProxy_Mixin 
  
  add_new_proxy @sprite 
  def initialize 
    @sprite=Sprite.new 
  end 
  
  
  
end 
  
proxy=ProxyTest.new 
proxy.visible=false #其实是将sprite的visible设置为false 
 于是乎现在不知道该怎么办于是就来求助了=-=。求解答
 |