Well, first off, 'draw_text' needs 5 arguments (or 2 if you use a Rect) to define x-coord, y-coord, width, height, and the string. In your method '
self.map_text' you are returning an array, which would only satisfy one of the five arguments. You will most likely have to call '
self.map_text' and store its result in a temporary variable. Like such:
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test").width
a = Config.map_text(@index) # a will be our temporary array
self.contents.draw_text(a[0], a[1], a[2], a[3], a[4])
end
You will have to use @index instead of index as your parameter when calling '
self.map_text' by the way.
Also, cx in 'refresh' and '
self.map_text' are local variables--they don't share the same values. Not to mention, they're not even in the same class.
Rewrite your script so that '
self.map_text' doesn't use cx, but 'refresh' still does.
def self.map_text(index)
return case index
when 193 then [0, 0, 32, "test"]
end
def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
cx = contents.text_size("test").width
a = Config.map_text(@index) # a will be our temporary array
self.contents.draw_text(a[0], a[1], cx, a[2], a[3])
end