Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Gosu::Building 2D Game with Ruby
- - By goofyfoot Date 2019-01-08 00:23
Howdy All I am new here and an just above novice in Ruby. Have experience with Web Development language necessities  and C# /Unity. So not a total blockhead, I am getting an error message. More so a DEPRECATION WARNING working from the command prompt. This is the ending code that is working fine. @font.draw(##) is what I think the warning is pointing to,

def draw
    if @visible > 0
    @image.draw(@x - @width / 2, @y - @height /2, 1)
    @hammer_image.draw(mouse_x - 40, mouse_y - 10,1)
    if @hit == 0
      c = Gosu::Color::NONE
    elsif @hit == 1
      c = Gosu::Color::GREEN
    elsif @hit == -1
      c =Gosu::Color::RED
    draw_quad(0, 0, c, 800, 0, c, 800, 600, c, 0, 600, c)
    @hit = 0
    @font.draw(@score.to_s, 700, 20, 2)

it offers this message in the console:

" DEPRECATION WARNING: draw is deprecated; use Font#draw_text or Font#draw_markup instead. draw called from whack_a_ruby.rb:59:in draw'. " that is what is showing in the console. To use either of them is commenting out the code?? Should I ignore a warning in the command prompt and the score counter works fine.

Can anyone please explain, thanks and just a bit confused by it, and to add. It is adding or subtracting to the score as the code is running...Peace.....
Parent - By bestguigui Date 2019-01-08 11:09
Hi !

Gosu changed a little the use of Gosu::Font. You have to use the method draw_text instead of draw, and that warning message will go away :)
Up Topic Gosu / Gosu Exchange / Gosu::Building 2D Game with Ruby

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill