Cursor de comando animado
3 participantes
Brasil G4mes :: Scripts :: Scripts RGSS2
Página 1 de 1
Cursor de comando animado
Um script que adiciona um cursor de comando animado nos menus.
- Código:
=begin
Janela de Comando Avançada
Por BigEd781
=end
module EdsCursorConfig
# Imagem do cursor, preferencialmente no tamanho 18x18 pixels.
POINTER_NAME = 'Pointer'
end
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_initialize :initialize
def initialize(width, commands, column_max = 1, row_max = 0, spacing = 32)
@arrow_image = Cache.picture(EdsCursorConfig::POINTER_NAME)
@arrow_sprite = Sprite.new
@arrow_sprite.bitmap = Bitmap.new(@arrow_image .width + 7, @arrow_image .height)
@arrow_sprite.z = 999
@sprite_last_draw_x = 0
@sprite_inc_x = 1
@intern_frame_count = 0
@update_pointer = true
eds_pre_window_command_mod_initialize(width, commands, column_max, row_max, spacing)
end
#--------------------------------------------------------------------------
# * dispose
#--------------------------------------------------------------------------
def dispose
super
@arrow_sprite.dispose
end
#--------------------------------------------------------------------------
# * close
#--------------------------------------------------------------------------
def close
super
@arrow_sprite.visible = false
end
#--------------------------------------------------------------------------
# * open
#--------------------------------------------------------------------------
def open
super
@arrow_sprite.visible = true
end
#--------------------------------------------------------------------------
# * visible=
#--------------------------------------------------------------------------
def visible=(value)
super
@arrow_sprite.visible = value ? (@index != -1) : value
end
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@update_pointer = value
end
#--------------------------------------------------------------------------
# * cursor_rect= (OVERWRITTEN)
#--------------------------------------------------------------------------
def cursor_rect=(rect)
offset_y = self.viewport.nil? ? 0 : self.viewport.rect.y
offset_x = self.viewport.nil? ? 0 : self.viewport.rect.x - self.viewport.ox
boost_y = @arrow_image.height >= 29 ? 0 : 29 - @arrow_image.height
@arrow_sprite.x = 5 + rect.x + self.x - (@arrow_image.width / 2) + offset_x
@arrow_sprite.y = rect.y + self.y + (@arrow_image.height / 2) + offset_y + boost_y
end
#--------------------------------------------------------------------------
# * update_cursor
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_update_cursor :update_cursor
def update_cursor
eds_pre_window_command_mod_update_cursor
@intern_frame_count += 1
draw_pointer
end
#--------------------------------------------------------------------------
# * draw_pointer
#--------------------------------------------------------------------------
def draw_pointer
return unless @update_pointer
return unless (@intern_frame_count % 5) == 0
@arrow_sprite.bitmap.clear
return if @index == -1
if @sprite_last_draw_x == 7
@sprite_inc_x = -1
elsif @sprite_last_draw_x == 0
@sprite_inc_x = 1
end
x = @sprite_last_draw_x + @sprite_inc_x
@sprite_last_draw_x = x
@arrow_sprite.bitmap.blt(x, 0, @arrow_image, @arrow_image.rect)
end
end
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@arrow_sprite.visible = value
end
end
class Window_Skill < Window_Selectable
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@arrow_sprite.visible = value
end
end
class Window_MenuStatus < Window_Selectable
#--------------------------------------------------------------------------
# * cursor_rect= (OVERWRITTEN)
#--------------------------------------------------------------------------
def cursor_rect=(rect)
@arrow_sprite.x = rect.x + self.x - 16
@arrow_sprite.y = rect.y + self.y + 48
end
#--------------------------------------------------------------------------
# * active=
#--------------------------------------------------------------------------
def active=(value)
super
@arrow_sprite.visible = value
end
#--------------------------------------------------------------------------
# * update_cursor
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_stat_update_cursor :update_cursor
def update_cursor
eds_pre_window_command_mod_stat_update_cursor
@intern_frame_count += 1
draw_pointer
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * start_main
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_start_main :start_main
def start_main
@party_command_window.visible = false
@actor_command_window.visible = false
eds_pre_window_command_mod_start_main
end
#--------------------------------------------------------------------------
# * start_party_command_selection
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_start_party_command_selection :start_party_command_selection
def start_party_command_selection
@party_command_window.visible = true
eds_pre_window_command_mod_start_party_command_selection
@actor_command_window.visible = false
end
#--------------------------------------------------------------------------
# * start_actor_command_selection
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_start_actor_command_selection :start_actor_command_selection
def start_actor_command_selection
@actor_command_window.visible = true
eds_pre_window_command_mod_start_actor_command_selection
@party_command_window.visible = false
end
end
class Window_Message < Window_Selectable
#--------------------------------------------------------------------------
# * update_cursor
#--------------------------------------------------------------------------
alias :eds_pre_window_command_mod_win_mes_update_cursor :update_cursor
def update_cursor
eds_pre_window_command_mod_win_mes_update_cursor
@intern_frame_count += 1
draw_pointer
end
end
Instruções:Cole o script acima do main. O cursor será defenido através de uma imagem chamada "pointer" que deve estar na pasta Pictures do projeto. Aqui tá um de exemplo que peguei na demo:
Créditos:
BigEd781
Yoshi
vitormenzani (se quiserem)
vitormenzani- Membro
- Mensagens : 187
Fama : 25
Re: Cursor de comando animado
Uia! Ele funciona com outros menus?
De onde voce tirou o script? +fama
De onde voce tirou o script? +fama
Robin312- Membro
- Mensagens : 247
Fama : 15
Re: Cursor de comando animado
Obrigado por me dar créditos
ZUERA gnt esse yoshi não sou eu oks?
Mto bom o script! Gosto bastante dele, usava ele nos meus jogos^^
ZUERA gnt esse yoshi não sou eu oks?
Mto bom o script! Gosto bastante dele, usava ele nos meus jogos^^
Brasil G4mes :: Scripts :: Scripts RGSS2
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos