michaelfairley/hasu

I want my initializer arguments!

Closed this issue · 3 comments

Hey! Very cool project, the quick resetting has been really helpful so far. Now however I needed to send in arguments to my Window object, and it just swallows everything up. Any way of creating my own instance instead of calling .run directly on the class?

...and like I always do right after I ask a stupid question - I figured out the answer myself. For future reference:

require 'hasu'

class MyWindow < Gosu::Window
  prepend Hasu::Guard

  def initialize(width, height)
    super(width, height, false)

    # call reset manually the first time if you need it
    reset
  end

  def reset
    # normal hasu reset code
  end
end

# Initialize it the Gosu way, with arguments and Hasu goodies still working
MyWindow.new(640, 480).show

Doh. That's definitely a miss on my part.

I just pushed 0.1.5 which lets run take arguments and pass them to initialize.

Even better, thanks! :-)