Scenes Background & Animations
Version: 1.00
Introduction
This script will add a background and transitions to all the scenes inherited from SDK::Scene_Base, and automagically move these scenes windows when the scene is activated. You can setup windows opacity for specific scenes.
Script
Instructions
There are some hashes in the TibudaScenes class. The hashes names explains everything. The hash syntax is {Scene_Class => value, Scene_Class => value, ...}. Where value can be and string with an Title filename, and Bitmap using RPG::Cache.type(filename), an Proc initializing a sprite or a plane. You can add an animated panorama to the background setting the value to
The other constant (Animations_frames) is an integer for the animations duration in frames.
Compatibility
Requires SDK 2.2 parts I and III. You need the MACL 1.5 or newer, in order to use animated windows.
Credits and Thanks
Trickster for the scrolling panorama method from his warp menu, and the SDK team for the auto-updating/disposing method, the base for the auto-moving method.
Version: 1.00
Introduction
This script will add a background and transitions to all the scenes inherited from SDK::Scene_Base, and automagically move these scenes windows when the scene is activated. You can setup windows opacity for specific scenes.
Script
Code:
#============================================================================
# ** Tibuda Scenes
#----------------------------------------------------------------------------
# Tibuda
# 1.00
# 04.11.2007
#============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Tibuda Scenes', 'Tibuda', 1.00, '04.11.2007')
#--------------------------------------------------------------------------
# SDK Requirement Check
#--------------------------------------------------------------------------
SDK.check_requirements(2, [1, 3])
#--------------------------------------------------------------------------
# Begin SDK Enabled Check : Tibuda Scenes
#--------------------------------------------------------------------------
if SDK.enabled?('Tibuda Scenes')
#==========================================================================
module TibudaScenes
#--------------------------------------------------------------------------
Panorama = {Scene_Title => proc {Plane_Panorama.new('006-Mountains01', 0, 1, 0) },
Scene_Map => nil}
Panorama.default = proc { Plane_Panorama.new('001-Sky01') }
Background = {Scene_Title => nil, Scene_Load => nil, Scene_Save => nil, Scene_Map => nil}
Background.default = :map
Transitions = {Scene_Title => nil, Scene_Map => nil}
Transitions.default = '006-Stripe02'
#--------------------------------------------------------------------------
Back_opacity = {Scene_Battle => 255}
Back_opacity.default = 192
Opacity = {}
Opacity.default = 255
#--------------------------------------------------------------------------
Animated = {Scene_Battle => false,
Scene_Map => false}
Animated.default = true
Animation_frames = 30
#--------------------------------------------------------------------------
def self.get_background(clas, pan = false)
hash = pan ? TibudaScenes::Panorama : TibudaScenes::Background
bg = hash[clas]
bg = bg[rand(bg.size)] if bg.is_a?(Array)
if bg.is_a?(Color)
ret = Sprite.new
ret.bitmap = Bitmap.new(640, 480)
ret.bitmap.fill_rect(0, 0, 640, 480, bg)
elsif bg == :map
return if $scene.is_a?(Scene_Map) || !$game_map.is_a?(Game_Map)
ret = Spriteset_Map.new
elsif bg.is_a?(Tone)
return if $scene.is_a?(Scene_Map) || !$game_map.is_a?(Game_Map)
ret = Spriteset_Map.new
ret.viewport1.tone = bg
elsif bg.is_a?(Bitmap)
ret = Sprite.new
ret.bitmap = bg
elsif bg.is_a?(Proc)
ret = bg.call
elsif bg.is_a?(Class)
ret = bg.new
elsif bg.is_a?(String)
ret = Sprite.new
ret.bitmap = RPG::Cache.title(bg)
else
return nil
end
ret.z = -1000 if pan
return ret
end
#--------------------------------------------------------------------------
end
#==========================================================================
# Code from Trickster's Warp Menu
#==========================================================================
class Plane_Panorama < Plane
#-------------------------------------------------------------------------
def initialize(panorama, hue = 0, speed = 5, scroll = 45)
# Make panorama plane
super()
# Setup Z
self.z = -1000
# Setup Panorama Bitmap
self.bitmap = RPG::Cache.panorama(panorama, hue)
# Get Angle (deg)
angle_deg = scroll.nil? ? rand(360) : scroll
# Set Angle (radians)
angle = angle_deg * Math::PI / 180
# Get Scroll X
@scroll_x = Math.cos(angle) * speed
# Get Scroll Y
@scroll_y = Math.sin(angle) * speed
end
#-------------------------------------------------------------------------
def update
# Scroll Panorama Horizontally
self.ox += @scroll_x
# Scroll Panorama Vertically
self.oy += @scroll_y
end
#-------------------------------------------------------------------------
end
#==========================================================================
class SDK::Scene_Base
#--------------------------------------------------------------------------
def main_bground
return if $scene.is_a?(Scene_Map)
@panorama = TibudaScenes.get_background(self.class, true)
@background = TibudaScenes.get_background(self.class, false)
end
#--------------------------------------------------------------------------
alias_method :tibuda_anim_scene_base_main, :main
def main
main_bground
tibuda_anim_scene_base_main
end
#--------------------------------------------------------------------------
alias_method :tibuda_anim_scene_base_main_transition, :main_transition
def main_transition
transition = TibudaScenes::Transitions[self.class]
if transition.nil?
tibuda_anim_scene_base_main_transition
else
Graphics.transition(40, "Graphics/Transitions/#{transition}")
end
end
#--------------------------------------------------------------------------
def auto_move(object, force = false)
# Return If Object isn't a Hash, Array or Respond to Move
return unless object.is_a?(Hash) || object.is_a?(Array) ||
object.respond_to?(:move)
# If Hash Object
if object.is_a?(Hash)
object.each do |key, value|
# Pass Key & Value to Auto Move
auto_move(key) ; auto_move(value)
end
return
end
# If Array Object
if object.is_a?(Array)
# Pass All Object to Auto Move
object.each {|obj| auto_move(obj)}
return
end
# If Responds to Move
if object.respond_to?(:move)
# If Responds to Disable Move & Move Disabled
if !force && object.respond_to?(:disable_move?) && object.disable_move?
# Return
return
end
# Set destination coords
dest_x = object.x
dest_y = object.y
# Set source coords
if object.y < 64
object.y = - object.height
elsif object.y >= 288
object.y = 480
elsif object.x < 160
object.x = - object.width
else
object.x = 640
end
# Set speed
speed = ((dest_x - object.x) ** 2 + (dest_y - object.y) ** 2) ** 0.5
speed /= TibudaScenes::Animation_frames
# Move Object
object.move(dest_x, dest_y, speed)
end
end
#--------------------------------------------------------------------------
alias_method :tibuda_anim_scene_base_main_audio, :main_window
def main_audio
tibuda_anim_scene_base_main_audio
if TibudaScenes::Animated[self.class]
# Passes Through All Instance Variables
self.instance_variables.each do |object_name|
# Evaluates Object
object = eval object_name
# Pass Object To Auto Move
auto_move(object)
end
end
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_Base
#--------------------------------------------------------------------------
alias_method :tibuda_anim_win_base_init, :initialize
def initialize(x, y, width, height)
tibuda_anim_win_base_init(x, y, width, height)
unless TibudaScenes::Back_opacity[$scene.class].nil?
self.back_opacity = TibudaScenes::Back_opacity[$scene.class]
end
unless TibudaScenes::Opacity[$scene.class].nil?
self.opacity = TibudaScenes::Opacity[$scene.class]
end
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
attr_accessor :viewport1
#--------------------------------------------------------------------------
def disable_update?
return !$scene.is_a?(Scene_Map)
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Window_EquipItem
#--------------------------------------------------------------------------
def disable_move?
return true
end
#--------------------------------------------------------------------------
end
#==========================================================================
class Scene_Equip
#--------------------------------------------------------------------------
alias_method :tibuda_anim_scn_equip_main_window, :main_window
def main_window
tibuda_anim_scn_equip_main_window
auto_move(@item_window, true) if TibudaScenes::Animated[Scene_Equip]
end
#--------------------------------------------------------------------------
end
#==========================================================================
end
#--------------------------------------------------------------------------
# End SDK Enabled Test : Tibuda Scenes
#--------------------------------------------------------------------------
Instructions
There are some hashes in the TibudaScenes class. The hashes names explains everything. The hash syntax is {Scene_Class => value, Scene_Class => value, ...}. Where value can be and string with an Title filename, and Bitmap using RPG::Cache.type(filename), an Proc initializing a sprite or a plane. You can add an animated panorama to the background setting the value to
Code:
proc {Plane_Panorama.new(panorama, hue, speed, angle)}
Compatibility
Requires SDK 2.2 parts I and III. You need the MACL 1.5 or newer, in order to use animated windows.
Credits and Thanks
Trickster for the scrolling panorama method from his warp menu, and the SDK team for the auto-updating/disposing method, the base for the auto-moving method.