Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Gosu::Image.new errors...
- - By timmcd Date 2009-10-01 23:52
My code causing the issue:
    7.times do |t|
      @anim << Gosu::Image.new(self,"images/#{t+1}.png", false)
    end

Error:
main.rb:12:in initialize': Wrong arguments for overloaded method 'Image.new'. (ArgumentError)
Possible C/C++ prototypes are:
    Image.new(Gosu::Window &window, VALUE source, bool tileable)
    Image.new(Gosu::Window &window, VALUE source, bool tileable, unsigned int srcX, unsigned int srcY, unsigned int srcWidth, unsigned int srcHeight)
  from main.rb:12:in
new'
  from main.rb:12:in block in initialize'
  from main.rb:11:in
times'
  from main.rb:11:in initialize'
  from main.rb:24:in
new'
  from main.rb:24:in `<main>'

Whats up here?
Parent - By BlueScope Date 2013-02-18 22:40
Because this is quite an annoying thing to debug because of the vague error message, let whoever else finding this thread point in the right direction:
This happens if you try to initialize an image before you call the Window as a superclass, for example like this:

class Game < Window
  def initialize
    @image = Image.new(self, 'sprite.png')
    super(640, 480, false)
  end
end


If you put the image after the super() call, it will work flawlessly - granted everything else is as it should be ;)
- By jlnr (dev) Date 2009-10-02 08:00
What is "self" in this context?
Up Topic Gosu / Gosu Exchange / Gosu::Image.new errors...

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill