I don't know if this is the right place to place this, if not please feel free to move this post.
I've made an extra button in my menu called "torch" and when you click this it asks if you want to use the torch. When you click "use torch" I've got my script to show a picture and when you click "put torch away" it disposes the picture.
The problem is that when I go back to my menu, not only the window of the question and the command window disposes, but also the picture. But I actually want the picture to keep showing until I go back to my menu again and click "deactivate torch".
Does somebody know how to fix this?
This is my script:
#==============================================================================
# ** Scene_Torch
#------------------------------------------------------------------------------
# This class asks if you want to open the torch
#==============================================================================
class Scene_Torch
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def main
# Make background transparant
@background = Spriteset_Map.new
# Make ask window
@torchAsk_window = Window_TorchAsk.new
# Make command window
s1 = $data_system.words.item
s2 = $data_system.words.skill
s3 = $data_system.words.equip
s4 = "Torch"
s5 = "Status"
s6 = "Save"
s7 = "End Game"
@commandInTorch_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7])
@commandInTorch_window.y = 480 - @commandInTorch_window.height
@commandInTorch_window.cursor_rect.set(0, 3 * 32, @commandInTorch_window.width - 32, 32)
@commandInTorch_window.active = false
# Make command window
s1 = "Use Torch"
s2 = "Put torch away"
@torch_window = Window_Command.new(192, [s1, s2])
@torch_window.x = 300
@torch_window.y = 320
# Make gold window
@gold_window = Window_Gold.new
@gold_window.x = 640 - @gold_window.width
@gold_window.y = 0
# Make window's opacity less
@commandInTorch_window.back_opacity = 160
@torch_window.back_opacity = 160
@torchAsk_window.back_opacity = 160
@gold_window.back_opacity = 160
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame Update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of window
@torch_window.dispose
@torchAsk_window.dispose
@background.dispose
@commandInTorch_window.dispose
@gold_window.dispose
# If switching to title screen
if $scene.is_a?(Scene_Title)
# Fade out screen
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@torch_window.update
@torchAsk_window.update
@background.update
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(3)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @torch_window.index
when 0 # Torch
command_torch
when 1 # Torch Away
command_torch_away
end
return
end
end
#--------------------------------------------------------------------------
# * Process When Choosing [Use Torch] Command
#--------------------------------------------------------------------------
def command_torch
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make torch graphic
@torchPicture = Sprite.new
@torchPicture.bitmap = RPG::Cache.picture("Torch")
end
#--------------------------------------------------------------------------
# * Process When Choosing [Put Torch Away] Command
#--------------------------------------------------------------------------
def command_torch_away
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Dispose of torch graphic
@torchPicture.bitmap.dispose
@torchPicture.dispose
end
end
#==============================================================================
# ** Window_TorchAsk
#----------------------------------------------------------------------------
# This window displays the question if you want to use your torch
#==============================================================================
class Window_TorchAsk < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(160, 224, 480, 96)
# super(0, 0, 640, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.z = 200
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
# self.contents.draw_text(width*0.25, -15, width, height,"Would you like to open your torch?")
self.contents.draw_text(width*0.15, -15, width, height,"Would you like to use your torch?")
self.contents.font.color = normal_color
end
end
Hello people,
I don't know if this is the right place to place this, if not please feel free to move this post.
I've made an extra button in my menu called "torch" and when you click this it asks if you want to use the torch. When you click "use torch" I've got my script to show a picture and when you click "put torch away" it disposes the picture.
The problem is that when I go back to my menu, not only the window of the question and the command window disposes, but also the picture. But I actually want the picture to keep showing until I go back to my menu again and click "deactivate torch".
Does somebody know how to fix this?
This is my script:
Share this post
Link to post
Share on other sites