0

I am trying to make text appear on a FXCanvas. when I use this code:

def score_box(event)
FXDCWindow.new(@canvas) do |dc|

    dc.drawText(640, 450, @score)
end     
end  

but it gives me an error saying I need to select a font, how do I do this? or could you provide anyway to make text on a canvas? Thanks

-bipolarpants

Adam Ashwal
  • 1,472
  • 1
  • 19
  • 36

1 Answers1

0

You need to select an FXFont object into the device context (dc), e.g.

FXDCWindow.new(@canvas) do |dc|
  font = FXFont.new(...)
  font.create
  dc.font = font
  dc.drawText(640, 450, @score)
end
  • So now I get no error (cool!) but no visible words are seem to be displayed in the FXCanvas. I changed the font to 24 and made the x and y in the middle so I could clearly see it if it were there. – Adam Ashwal Nov 15 '10 at 23:10
  • I figure it out, the color must have been set to white, all I had to do was change it to another one. – Adam Ashwal Nov 16 '10 at 13:03