Skip to content

Instantly share code, notes, and snippets.

@HimeWorks
Created March 23, 2015 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HimeWorks/8ce4e14a3bbe81db2bf3 to your computer and use it in GitHub Desktop.
Save HimeWorks/8ce4e14a3bbe81db2bf3 to your computer and use it in GitHub Desktop.
Simple Menu Cursor
class Sprite_Cursor < Sprite
def initialize(viewport=nil, window)
super(viewport)
@window = window
@name = "Menu_Cursor"
end
def update
super
update_visibility
update_bitmap
update_position
end
def update_bitmap
self.bitmap = Cache.system(@name)
end
def update_visibility
@index = @window.index
if @window.close?
self.visible = false
elsif !@window.visible
self.visible = false
elsif @index < 0
self.visible = false
else
self.visible = true
end
end
def update_position
@index = @window.index
rect = @window.item_rect(@index)
self.x = @window.x + rect.x
self.y = @window.y + rect.y
self.z = @window.z + 100
end
def dispose
self.bitmap.dispose
super
end
end
class Window_Selectable
alias :th_menu_cursor_initialize :initialize
def initialize(*args)
@sprite_cursor = Sprite_Cursor.new(self)
th_menu_cursor_initialize(*args)
end
alias :th_menu_cursor_update :update
def update
@sprite_cursor.update
th_menu_cursor_update
end
alias :th_menu_cursor_dispose :dispose
def dispose
@sprite_cursor.dispose
th_menu_cursor_dispose
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment