繁体   English   中英

无法在Ruby中使用Gosu打印文本

[英]Cannot print a text with Gosu in Ruby

我坐在这里,我觉得那是一个非常简单的错误,我只是想不起来。.我试图学习如何使用Gosu gem和Ruby制作游戏,但是却遇到了麻烦。 这是我的代码。

require "gosu"

class Hello < Gosu::Window
    def initialize width = 800, height = 600, fullscreen = false
    super
    self.caption = "Ruby Practise"
    @image = Gosu::Image.from_text self. "My text to print".
                            Gosu.default_font_name.
                            100
    end
    def button_down id
        close if id == Gosu::KbEscape
    end
    def update
    end
    def draw
        @image.draw 0, 0, 0
    end
end
Hello.new.show

有问题,但我不知道是什么。 我花了至少1个小时。.它抱怨String,这是终端的输出。

hello.rb:8: syntax error, unexpected tSTRING_BEG
    @image = Gosu::Image.from_text self. "My text to print".
                                              ^
hello.rb:10: syntax error, unexpected tINTEGER

我不是我做错了,有人知道吗? 这可能真的很简单。

使用逗号分隔函数参数,而不是点:

@image = Gosu::Image.from_text self, "My text to print",
                        Gosu.default_font_name,
                        100

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM