Hello world! I need help! I read Gosu documentation, but not found method for delete images from window:
def initialize window, x, y
@image = Gosu::Image.new(window, "images/cheese.png", false)
@x, @y = x, y
@image.draw(@x, @y, 1)
#what I write here for delete image? In Gosu::Image documentation i not found answer for my question
Thanks for all, and sorry for my English!
@image = nil will "delete" the image, but that will cause problems when drawing. You could change your draw to
@image.draw(@x,@y,1) if @image != nil.
I think you might be confused about how Gosu works... The window isn't a persistent canvas you have to manage on your own. The Window#draw method is called periodically, and everything you tell it to draw within that method is drawn on a fresh, blank surface. If you want an image to stay on the screen, you just have to tell Gosu to draw it. If you don't want it to be visible, don't draw it. Looking at the examples should make it clear.
Also, for your above code to work, you'll have to call Cheese#draw (which means: "the draw method of an instance of the Cheese class") within your Window's draw method. When you update the Cheese instance's x and y coordinates, it will move to the new position on the screen automatically.
Thank you very match. I'm novice in game development
Some of us still are... -_-' ' '
lol I'm still a novice too!
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill