width = 100
height = 100
@image = Gosu::Image.new(@window, [width, height], false)
TexPlay.create_image(window, width, height)
:color => color
at the end.
class EmptyImageSource < Struct(:columns, :rows)
def to_blob; "\0" * columns * rows * 4; end;
end
empty_image = Gosu::Image.new(window, EmptyImageSource.new(width, height), ...)
cols
instead of columns
.
TestGosuTexPlay.rb:4:in <main>': undefined method
Struct' for main:Object (NoMethodError)
@image = Gosu::Image.new(window, EmptyImageSource.new(100, 100), tileable, rect_x, rect_y, rect_width, rect_height)
@image.rect_x = x
@image.rect_y = y
@image.rect_width = width
@image.rect_height = height
@image.set_rect(x, y, width, height)
x
/y
? From Gosu's PoV, an Image has no position. You can move an image in itself without Texplay by calling @image.insert(@image, offset_x, offset_y)
. Gosu does not allow you to resize an image though, and Texplay cannot do this without creating a new image either.
class Window_Command < Window_Base
def initialize(width, commands)
self.width = width
self.height = 64 # Window height
@index = 0
@commads = commands
@cursor = Sprite.new
@cursor.bitmap = Bitmap.new('cursor.png') # Bitmap is equal Gosu::Image but Bitmap is created by my.
self.contents = Bitmap.new(width, commands.length * 32) # width = 192; height = 96
self.contents.src_rect = Rect.new(0, 0, self.width, self.height) # Not show beyond the window height.
refresh
end
def refresh
self.contents.clear
for c in 0...@commands.length # 0, 1, 2
draw_item(@commands[c], c)
end
end
def draw_item(text, index)
self.contents.draw_text(0, index * 32, text) # (x, y, string) I need to create this method.
end
def update
if Keyboard.trigger?(:Down)
@index += 1
elsif Keyboard.trigger?(:Up)
@index -= 1
end
@cursor.y = @index * 32
update_src_rect
end
def update_src_rect
case @index
when 0..1 then self.contents.src_rect.y = 0
when 3 then self.contents.src_rect.y = 32
end
end
end
window_commands = Window_Command(192, ['New Game', 'Continue', 'Exit'])
if Keyboard.trigger?(:Enter)
case window_commands.index
when 0 # New Game
when 1 # Continue
when 2 # Exit
end
end
clip_to(rect) { your_rendering_code_here }
. clip_to
works with screen coordinates, not texture coordinates, but will do what you want - cut off what should be invisible.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill