hey guys, iv been getting into scripting and thought id start with a custom window, im having trouble with my script though, so i have a map scene here, which draws a map, and has an index to grid the map up, the problem is my index cursor is being drawn behind the map image, the only way i can see it is if i reduce the opacity of the maps image, which makes my map look really dull as it is merging it with the color scheme of my windowskin, so i need to change the self.z of either the index's cursor, or the image, heres my script as it stands:
hey guys, iv been getting into scripting and thought id start with a custom window, im having trouble with my script though, so i have a map scene here, which draws a map, and has an index to grid the map up, the problem is my index cursor is being drawn behind the map image, the only way i can see it is if i reduce the opacity of the maps image, which makes my map look really dull as it is merging it with the color scheme of my windowskin, so i need to change the self.z of either the index's cursor, or the image, heres my script as it stands:
#==============================================================================
# ** Window_Map
#------------------------------------------------------------------------------
class Window_MapMenu < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 640, 480)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#-------------------------------------------------------------------------
# * def index
#-------------------------------------------------------------------------
def index=(index)
@index = index
# Update cursor rectangle
update_cursor_rect
end
#--------------------------------------------------------------------------
# * Cursor Rectangle Update
#--------------------------------------------------------------------------
def update_cursor_rect
x = 32 + @index % 17 * 32
y = 0 + @index / 17 % 14 * 32
self.cursor_rect.set(x, y, 32, 32)
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
@bitmap = RPG::Cache.picture("kantomap.png")
self.contents.blt(32, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 160)
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# if enter is being pressed
if Input.trigger?(Input::C)
if @index == 172
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_PalletTown.new
end
end
# If right directional button is pushed
if Input.repeat?(Input::RIGHT)
# If directional button pressed down is not a repeat, or
# cursor is not positioned on the right edge
if Input.trigger?(Input::RIGHT) or
@index % 17 < 16
# Move cursor to right
$game_system.se_play($data_system.cursor_se)
if @index % 17 < 16
@index += 1
end
end
end
# If left directional button is pushed
if Input.repeat?(Input::LEFT)
# If directional button pressed down is not a repeat, or
# cursor is not positioned on the left edge
if Input.trigger?(Input::LEFT) or
@index % 17 > 0
# Move cursor to left
$game_system.se_play($data_system.cursor_se)
if @index % 17 > 0
@index -= 1
end
end
end
# If down directional button is pushed
if Input.repeat?(Input::DOWN)
# Move cursor down
if @index / 17 < 13
@index += 17
$game_system.se_play($data_system.cursor_se)
end
end
# If up directional button is pushed
if Input.repeat?(Input::UP)
# Move cursor up
if @index / 17 > 0
@index -= 17
$game_system.se_play($data_system.cursor_se)
end
end
update_cursor_rect
end
end
#---------------------------------------------------------------------------
# * Scene Map_Menu
#---------------------------------------------------------------------------
class Scene_MapMenu
def initialize(index = 0)
@index = index
end
#-------------------------------------------------------------------------
# * MAIN
#-------------------------------------------------------------------------
def main
@mapmenu_window = Window_MapMenu.new
@mapmenu_window.index = @index
# 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 windows
@mapmenu_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@mapmenu_window.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_Item.new
return
end
end
end
#---------------------------------------------------------------------------
# * class Window_PalletTown
#---------------------------------------------------------------------------
class Window_PalletTown < Window_Base
#-------------------------------------------------------------------------
# * Object Initialization
#-------------------------------------------------------------------------
def initialize
super(0, 0, 416, 352)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#-------------------------------------------------------------------------
# * refresh
#-------------------------------------------------------------------------
def refresh
@bitmap = RPG::Cache.picture("pallettown.png")
self.contents.blt(0, 0, @bitmap, Rect.new(0, 0, @bitmap.width, @bitmap.height), 255)
end
end
#---------------------------------------------------------------------------
# * Scene_PalletTown
#---------------------------------------------------------------------------
class Scene_PalletTown
#-------------------------------------------------------------------------
# * Main
#-------------------------------------------------------------------------
def main
@pallettown_window = Window_PalletTown.new
# 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 windows
@pallettown_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@pallettown_window.update
# if mapmenu is active call update_map
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_MapMenu.new(172)
return
end
end
end
if anyone knows how i can solve this i would be very grateful, iv tried multiple solutions but to no avail :(
Share this post
Link to post
Share on other sites