Well, now I'm confused as to where you are putting it. If it is in a window, you should really just be drawing it onto the window's bitmap.
In any case, you'd want to do:
sprite.bitmap.dispose
sprite.dispose
if you're using a Sprite. However, if it's inside some other class than it wouldn't by default be accessible outside the class - you'd need to make it publicly accessible.
But like I said, if it's a window, then using the sprite is kind of weird. Not wrong, necessarily - it can certainly be very useful to control a sprite within a window and I've done it on occasion - just peculiar.
But yeah, it sounds as if you are trying to access the sprite from outside of the class you created it in, so just make it publicly accessible or else write a sprite dispose method in the class and call it. I'd need to know more about the infrastructure of the class before I could tell you anything more useful than that though.
It's definitely in a window. I modified the windows from Dubealex's Ruby tutorial, but I'm still uncomfortable with draw and windows script. The images are in the pictures directory. My roomate wants an "Organic Chemist" character class (don't ask) and I need to be able to stick images in her game.
Here's the script:
class Scene_Chapter3_menu1
def initialize(menu_index = 0)
@menu_index = menu_index #Store the cursor position
end
#--------------------------------------------------------------------------------------------------------
def main
@window_a1=Window_a1.new #Content Window
@window_a1.update(false) #Decide whether to show/hide the content...
@window_a1.x=160
@window_a1.y=0
# stuff goes here
s1 = "Items"
s2 = "Infos"
s3 = "Music A"
s4 = "Image"
s5 = "Exit"
@window_a2 = Window_Command.new(160, [s1,s2,s3,s4,s5]) #160 is width
@window_a2.y=0 #Set a position for the menu other than 0:0
@window_a2.height=480 #Force a new height for the menu window
@window_a2.index = @menu_index
# end stuff
#This is what makes the scene update itself constantly:
Graphics.transition
loop do
Graphics.update
Input.update
update #Call the method DEF UPDATE starting below
if $scene != self
break
end
end
#Execute when exiting the scene:
Graphics.freeze
@window_a1.dispose
@window_a2.dispose
#@window_a3.dispose #edited out with begins/ends etc.
end
#--------------------------------------------------------------------------------------------------------
#--------------------------------------------------------------------------------------------------------
def update
@window_a2.update #menu
#THIS IS FOR THE OPTION FUNCTIONS:
if Input.trigger?(Input::C) #Do the following if ENTER is pressed...
case @window_a2.index #window_a2 is the menu... index is it's cursor position !
when 0 #Remember that the cursor position start at 0, because it's an Array !!
item #item - s1
when 1
infos #infos -s2
when 2
music_a #Music A - s3
when 3
music_b #Music B - s4
when 4
exit #Exit - s5
end
end
# --- end stuff
if Input.trigger?(Input::B) #Press ESCAPE to exit
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
$game_map.autoplay #Because we play music in the menu...
end
end
#--------------------------------------------------------------------------------------------------------
#Options Method Start Here:
#actual result of options goes here.
def item #s1, menu_index=0
$game_system.se_play($data_system.decision_se) #play an SE
$scene = Scene_Item.new #Syntax to change scene
end
def infos #s2, menu_index=1
@window_a1.update(true)
$game_actors[9].str += 10 #works, added by shintashi
end
def music_a #s3, menu_index=2
Audio.bgm_play("Audio/BGM/043-Positive01.mid", 100, 100) #Play custom BGM
end
def music_b #s4, menu_index=3
sprite = Sprite.new
sprite.bitmap = RPG::Cache.picture ("adenosine") # <- Don't need to put the directory path
sprite.z, sprite.x, sprite.y = 120, 160, 0
# Audio.bgm_play("Audio/BGM/044-Positive02.mid", 100, 100) #Play custom BGM
#@window_a1.contents.clear # added by shintashi
end
def exit #s5, menu_index=4
$game_system.se_play($data_system.cancel_se) #play an SE
$scene = Scene_Map.new #Syntax to change scene
$game_map.autoplay #Because we play music in the menu...
end
# end actual result of options
#--------------------------------------------------------------------------------------------------------
end #of the Scene !
#===================================================
# CLASS Window_a1 BEGINS (Content Window)
#===================================================
class Window_a1 < Window_Base
def initialize
super(0, 0, 480,480)
self.contents = Bitmap.new(width-32, height-32)
self.contents.font.name = "Tahoma"
self.contents.font.size = 20
end
def update(content) #Receive the argument from the menu
if content == false #If false, don't show content
self.contents.clear
self.contents.draw_text(0, 0, 120, 32, "No Content...")
else #else, if true, show it...
self.contents.clear
self.contents.draw_text(0, 0, 440, 32, "STAT +10")
end
end
end