draw_circle
" method that draws an unfilled circle with a given edge thickness (using draw_quad), but I don't know how to integrate it into Gosu so it functions like draw_line
, etc.Gosu::Window
, and it works fine when called directly from within (a subclass of) Window#draw
. However, I want to call it from within the #draw
of another class, which is itself called inside Window#draw
. When I do, Ruby says the method is undefined. Okay, that kinda makes sense... I just have to call Window#draw_circle
, then, right? So, I pass a reference to the Window
object into my class' constructor, but calling @win.draw_circle(...)
makes the first call to draw_quad
inside draw_circle
fail with the message "invalid value
".draw_quad
, etc. are defined directly in the Gosu
module, I tried doing that with my draw_circle
, too, but then I can't figure out how to call it at all. It doesn't "just work" like calling draw_quad
, etc.def self.x
instead of def x
:module Gosu
def self.draw_circle
... draw_quad(...) ...
end
end
undefined method 'draw_circle' for #<GfxWindow:0x287bc20>
and, in the non-working example: undefined method 'draw_circle' for #<Connector:0x2944398>
Gosu::
" to the draw_circle
calls, the non-working example gives "invalid value" and the working example works again, but I don't have to add "Gosu::
" to draw_quad
, etc., so why should I now?
draw_quad
originally was (and still is) an instance method of Gosu::Window
, which is why you can call it without Gosu::
or Gosu.
inside of your window subclass, but only there.Gosu::Window
instance made it necessary to pass around references to the window everywhere (same thing with the old Image
constructors etc.), which was so annoying that many games used a global $window
variable instead. So in Gosu 0.9, I've moved all the draw_
methods into module Gosu
, along with button_down?
.draw_quad
methods now, one on Gosu::Window
and one in Gosu
itself. If you want draw_circle
to have the same behaviour, you'll need to implement it twice as well. The method in Gosu::Window
would just forward all arguments to the module.Gosu.draw_xxx
, but I'm afraid that'll make things even more confusing when someone uses include Gosu
.draw_circle
(and, thus, to the draw_rect
inside)!draw_circle
a class method of Gosu and made an instance method of Window pointing to it, and all works as it should!Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill