Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Chingu Animations -- Error: Undefined Method "to_blob"
- - By ml Date 2015-08-14 04:56 Edited 2015-08-14 10:16
Hi, I've been away from the Gosu forums for a while. It's nice to be back. Greetings and best wishes to all.

My old Ubuntu installation stopped working a while back, so I didn't use Gosu for a year or two, and now I've tried installing Gosu again, and my old games don't seem to be working like they used to.

I have currently installed Gosu / Chingu on a PC with Windows 10, and my brother is helping me out by trouble-shooting the same issues on a newer MacBook, with OSX 10.10.

I keep getting the same error -- Undefined Method "to_blob". This seems to occur mostly with code looking like @image = Gosu::Image.new(...) or similar.

Most of my old projects are affected. I have tried changing the gem versions of both Gosu and Chingu in the Gemfile, and I continue to get the same issue. Any ideas of what might be causing this? Included below is the stack trace from one of the broken games. They have pretty much all stopped working now. Any help will be appreciated. Thanks as always. Gosu is the greatest.

C:/Users/Matt/code/games/StickBall/rb/lense_flare.rb:85:in initialize': undefined method to_blob' for #<GameWindow:0x34c67e8> (NoMethodError)
        from C:/Users/Matt/code/games/StickBall/rb/lense_flare.rb:85:in initialize'
        from C:/Users/Matt/code/games/StickBall/rb/lense_flare.rb:85:in
new'
        from C:/Users/Matt/code/games/StickBall/rb/lense_flare.rb:85:in load_images'
        from C:/Users/Matt/code/games/StickBall/rb/lense_flares.rb:36:in
load_images'
        from C:/Users/Matt/code/games/StickBall/rb/beginning.rb:24:in initialize'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/game_state_manager.rb:277:in
new'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/game_state_manager.rb:277:in game_state_instance'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/game_state_manager.rb:118:in
push_game_state'
        from C:/Users/Matt/code/games/StickBall/rb/beginning.rb:12:in block in setup'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/traits/timer.rb:149:in
call'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/traits/timer.rb:149:in block in update_trait'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/traits/timer.rb:148:in
each'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/traits/timer.rb:148:in update_trait'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/game_state_manager.rb:249:in
update'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/window.rb:146:in intermediate_update'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/chingu-0.9rc9/lib/chingu/window.rb:114:in
update'
        from main.rb:136:in `<main>'

And here is the affected line of code from the above error log (lense_flare.rb:85):
    @@star_flare = Gosu::Image.new window, File.join(load_path, 'star_flare.png')

UPDATE: I have been able to resolve the issue with images by changing the syntax, but I am having the same issue with Chingu Animations, and I have not been able to fix it so far.

UPDATE: I wonder if this might have to do with the Ruby version... Perhaps Chingu Animations are not compatible with newer versions of Ruby?...
Parent - - By cyberarm Date 2015-08-15 15:13
What version of Gosu are you using?
0.9.0+ might break things in Chingu, does using an older version, such as 0.8.7 fix it?
Parent - - By jlnr (dev) Date 2015-08-16 13:00 Edited 2015-08-16 19:10
The strange thing is that Chingu does not alias any methods in Gosu::Image (monkey-patching). It seems to only use the public interface.

Since Gosu 0.9 is supposed to be backwards-compatible, it might be a bug in Gosu. (But testing with 0.8.7 is still worth a shot!)
Parent - By ml Date 2015-08-17 05:17
Thanks for the responses. I tried using various older versions of both Gosu and Chingu, with the same results, but I have not tried with an older version of Ruby yet. I will try with Ruby 1.9.3 and post the results when I get a chance.
Parent - By jlnr (dev) Date 2015-08-20 22:20
I've dug into it and Chingu by itself seems to work - no problem with any of Chingu's examples (at least, the five I've tried) and Gosu 0.10.0.

However, Ashton monkey-patches a lot of stuff in Gosu, and that might be the problem at hand. I know that everything in Ashton should actually be part of Gosu...but right now I don't have the resources to either implement it in Gosu or to fix the Ashton gem. Sorry :|
Parent - - By Monster52 Date 2015-08-28 17:47
I had a similar issue the other day using Chingu,  Try naming you image file like this: filename_32x32.png.  Where the 32x32 will be the width and height of the image.  This worked for me.
Parent - By ml Date 2015-11-24 23:51
Thank you for the suggestions.  I will try these out as soon as I am able.
Parent - By jlnr (dev) Date 2015-10-04 10:16
Oh man, in retrospect that was a really silly oversight on my part. Anyway, should be fixed in Gosu 0.10.4.
Up Topic Gosu / Gosu Exchange / Chingu Animations -- Error: Undefined Method "to_blob"

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill