Ruby Gosu Window Management Via Delegates
There are reasons why you can't just switch windows in gosu. You have to use single Window object and delegates
class Window < Gosu::Window
def initialize(name)
super(1024, 768, false)
set_delegate(name)
end
def draw
@delegate.draw
end
def update
@delegate.update
end
def set_delegate(name, opts={})
@delegate = Object.const_get(name).new(self, opts)
end
def method_missing(sym, *args, &block)
@delegate.send(sym, *args, &block)
end
end
Written by Nickolay Schwarz
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#