开发者

How to use drawText on FXCanvas in FXRuby?

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

def 开发者_如何学Pythonscore_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


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜