#==============================================================================
# +++ MOG - Animated Title A (v1.0) +++
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com/
#==============================================================================
# Tela de titulo animado, com logo, imagens aleatórias e outros efeitos visuais.
#==============================================================================
# Nota - Serão necessários as seguintes imagens na pasta Graphics/Titles2/
#
#
# Firefly.png
# Logo.jpg (Opcional - Caso for usar o efeito logo.)
#
#==============================================================================
# Para definir a imagem de texto basta selecionar no banco de dados
# a imagem do titulo numero 2 (Segunda camada)
#
#==============================================================================
module MOG_SCENE_TITLE_A
#Posição do comando.
COMMANDS_POS = [240 , 280]
#Ativar Particulas.
FIREFLY = false
#Ativar Logo
LOGO = false
#Duração do logo.
LOGO_DURATION = 2#(Sec)
#Definição da posição do cursor.(Para ajustes)
CURSOR_POS = [-42,-7]
end
#==============================================================================
# ■ Window TitleCommand
#==============================================================================
class Window_TitleCommand < Window_Command
attr_reader :list
end
#==============================================================================
# ■ FireFly
#==============================================================================
class Firefly < Sprite
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(viewport = nil)
super(viewport)
self.bitmap = Cache.title2("Firefly")
reset_setting
end
#--------------------------------------------------------------------------
# ● Reset Setting
#--------------------------------------------------------------------------
def reset_setting
zoom = (50 + rand(100)) / 100.1
self.zoom_x = zoom
self.zoom_y = zoom
self.x = rand(640)
self.y = rand(480 + self.bitmap.height)
self.opacity = 0
self.angle = rand(360)
self.blend_type = 1
@speed_x = 0
@speed_y = [[rand(4), 4].min, 1].max
@speed_a = rand(3)
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
super
self.bitmap.dispose
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
self.x += @speed_x
self.y -= @speed_y
self.angle += @speed_a
self.opacity += 5
reset_setting if self.y < 0
end
end
#==============================================================================
# ■ Scene Title
#==============================================================================
class Scene_Title < Scene_Base
include MOG_SCENE_TITLE_A
#--------------------------------------------------------------------------
# ● Start
#--------------------------------------------------------------------------
def start
super
RPG::BGM.fade(2000)
@logo_active = LOGO
SceneManager.clear
@phase = 1
@phase_time = -1
create_logo if @logo_active
create_command_window
create_commands
create_background
create_light
create_cursor
play_title_music unless @logo_active
end
#--------------------------------------------------------------------------
# ● create_background
#--------------------------------------------------------------------------
def create_background
@sprite1 = Sprite.new
@sprite1.bitmap = Cache.title1($data_system.title1_name)
@sprite2 = Plane.new
@sprite2.bitmap = Cache.title2($data_system.title2_name)
@sprite2.z = 100
@sprite2.opacity = 0
end
#--------------------------------------------------------------------------
# ● Create Light
#--------------------------------------------------------------------------
def create_light
return unless FIREFLY
@light_viewport = Viewport.new(-32, -32, 672, 542)
@light_bitmap =[]
for i in 0...20
@light_bitmap.push(Firefly.new(@light_viewport))
end
end
#--------------------------------------------------------------------------
# ● Create_Logo
#--------------------------------------------------------------------------
def create_cursor
@cursor = Sprite.new
@cursor.bitmap = Cache.title2("Cursor")
@cursor.opacity = 0
@cursor.z = 120
@cursor_position = [0,0]
@mx = [0,0,0]
end
#--------------------------------------------------------------------------
# ● Create_Logo
#--------------------------------------------------------------------------
def create_logo
@phase = 0
@logo = Sprite.new
@logo.bitmap = Cache.title2("Logo")
@logo.opacity = 0
@logo_duration = 180 + (LOGO_DURATION * 60)
end
#--------------------------------------------------------------------------
# ● Create Commands
#--------------------------------------------------------------------------
def create_commands
@command_window.visible = false
@commands_index_old = -1
@commands = []
@commands_shake_duration = 0
index = 0
for com in @command_window.list
sprite = Sprite.new
sprite.bitmap = Cache.title2(com[:name].to_s) rescue nil
if sprite.bitmap == nil
sprite.bitmap = Bitmap.new(200,32)
sprite.bitmap.font.size = 24
sprite.bitmap.font.bold = true
sprite.bitmap.font.italic = true
sprite.bitmap.draw_text(0, 0, 200, 32, com[:name].to_s,1)
end
sprite.x = COMMANDS_POS[0] - 100 - (index * 20)
sprite.y = index * sprite.bitmap.height + COMMANDS_POS[1]
sprite.z = 100 + index
sprite.opacity = 0
index += 1
@commands.push(sprite)
end
@command_max = index
end
#--------------------------------------------------------------------------
# ● dispose Background1
#--------------------------------------------------------------------------
def dispose_background1
@sprite1.bitmap.dispose
@sprite1.bitmap = nil
@sprite1.dispose
@sprite1 = nil
end
#--------------------------------------------------------------------------
# ● Dispose Background2
#--------------------------------------------------------------------------
def dispose_background2
if @sprite2.bitmap != nil
@sprite2.bitmap.dispose
@sprite2.bitmap = nil
@sprite2.dispose
@sprite2 = nil
end
end
#--------------------------------------------------------------------------
# ● Dispose Light
#--------------------------------------------------------------------------
def dispose_light
return unless FIREFLY
if @light_bitmap != nil
for i in @light_bitmap
i.dispose
end
@light_viewport.dispose
@light_bitmap = nil
end
end
#--------------------------------------------------------------------------
# ● Dispose Logo
#--------------------------------------------------------------------------
def dispose_logo
return unless LOGO
@logo.bitmap.dispose
@logo.dispose
end
#--------------------------------------------------------------------------
# ● Dispose Logo
#--------------------------------------------------------------------------
def dispose_logo
return unless @logo_active
@logo.bitmap.dispose
@logo.dispose
end
#--------------------------------------------------------------------------
# ● Terminate
#--------------------------------------------------------------------------
def terminate
super
dispose_background1
dispose_background2
dispose_light
dispose_logo
@cursor.bitmap.dispose
@cursor.dispose
for com in @commands
com.bitmap.dispose
com.dispose
end
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
def update
super
update_logo
update_initial_animation
update_command
update_background
update_light
end
#--------------------------------------------------------------------------
# ● Update Logo
#--------------------------------------------------------------------------
def update_logo
return if @phase != 0
loop do
break if @logo_duration == 0
execute_logo
Graphics.update
end
play_title_music
end
#--------------------------------------------------------------------------
# ● Update Cursor Position
#--------------------------------------------------------------------------
def update_cursor_position
@cursor.opacity += 5
execute_animation_s
execute_cursor_move(0,@cursor.x,@cursor_position[0] + @mx[1])
execute_cursor_move(1,@cursor.y,@cursor_position[1])
end
#--------------------------------------------------------------------------
# ● Execute Logo
#--------------------------------------------------------------------------
def execute_logo
@logo_duration -= 1
if @logo_duration > 120
@logo.opacity += 5
else
@logo.opacity -= 5
end
if @logo.opacity <= 0
@logo_duration = 0
@phase = 1
end
end
#--------------------------------------------------------------------------
# ● Execute Animation S
#--------------------------------------------------------------------------
def execute_animation_s
@mx[2] += 1
return if @mx[2] < 4
@mx[2] = 0
@mx[0] += 1
case @mx[0]
when 1..7; @mx[1] += 1
when 8..14; @mx[1] -= 1
else
@mx[0] = 0
@mx[1] = 0
end
end
#--------------------------------------------------------------------------
# ● Execute Cursor Move
#--------------------------------------------------------------------------
def execute_cursor_move(type,cp,np)
sp = 5 + ((cp - np).abs / 5)
if cp > np
cp -= sp
cp = np if cp < np
elsif cp < np
cp += sp
cp = np if cp > np
end
@cursor.x = cp if type == 0
@cursor.y = cp if type == 1
end
#--------------------------------------------------------------------------
# ● Update Background
#--------------------------------------------------------------------------
def update_background
@sprite2.opacity += 5
end
#--------------------------------------------------------------------------
# ● Update Light
#--------------------------------------------------------------------------
def update_light
return unless FIREFLY
if @light_bitmap != nil
for i in @light_bitmap
i.update
end
end
end
#--------------------------------------------------------------------------
# ● Update Initial Animation
#--------------------------------------------------------------------------
def update_initial_animation
return if @phase != 1
@phase_time -= 1 if @phase_time > 0
if @phase_time == 0
@phase = 2
@phase_time = 30
end
for i in @commands
index = 0
if i.x < COMMANDS_POS[0]
i.x += 5 + (2 * index)
i.opacity += 10
if i.x >= COMMANDS_POS[0]
i.x = COMMANDS_POS[0]
i.opacity = 255
if @phase_time < 15 / 2
@phase_time = 15
end
end
end
index += 1
end
end
#--------------------------------------------------------------------------
# ● Update Command
#--------------------------------------------------------------------------
def update_command
return if @phase != 2
update_command_slide
update_cursor_position
end
#--------------------------------------------------------------------------
# ● Update Command Slide
#--------------------------------------------------------------------------
def update_command_slide
if @commands_index_old != @command_window.index
@commands_index_old = @command_window.index
@commands_shake_duration = 30
end
return if @commands_shake_duration == 0
@commands_shake_duration -= 1 if @commands_shake_duration > 0
for i in @commands
if (i.z - 100) == @command_window.index
i.opacity += 10
@cursor_position = [COMMANDS_POS[0] + CURSOR_POS[0],i.y + CURSOR_POS[1]]
i.x = COMMANDS_POS[0] + rand(@commands_shake_duration)
else
i.opacity -= 7 if i.opacity > 100
i.x = COMMANDS_POS[0]
end
end
end
end
$mog_rgss3_animated_title_a = true