Transition Pack Add-Ons
Authors: ForeverZer0
Version: 1.0
Type: Custom Transitions
Key Term: Misc Add-on
IntroductionThis is a thread to post additional transition to use with Fantasist's Transition Pack, which can be found here:
http://forum.chaos-project.com/index.php/topic,1390.0.htmlI would normally post this in the thread for the script, or submit it to see if it could be added, but the original auhor of the script is no longer active on the forum.
IntructionsAdding them is easy, just follow these steps:
- Copy and paste the code for the transition you would like to add to the original script.
- Find the "call_effect" method near the top of the script.
- Create a new line before the "end" in the case statements ( "when NUMBER then .... ")
- Follow the pattern, and add your own line, like this:
when NUMBER then METHOD_NAME
- Repeat this process in the second part of the "call_effect" method, but this time add a "(*args)" to the end of the line:
when NUMBER then METHOD_NAME(*args)
- You can now call the method with the number that you defined in the lines you added!
Adding Sound Effects
To add a sound effect, simply add a line into the desired method like this.
$game_system.se_play(RPG::AudioFile.new('SE_FILENAME', VOLUME, PITCH))
SE_FILENAME: Name of a file in the Audio/SE directory. Must be a string (within ' ' or " ").
VOLUME: Desired volume to use for sound effect. (0 - 100)
PITCH: Desired pitch to use for sound effect. (50 - 150)
It is important to pay attention as to where you place the line.
Placing it in the middle of an iteration will cause the game to attempt to play the sound effect many times per second (usually). If you are in doubt, it will usually be okay to simply place it at the beginning of the method, or just experiment around to see what best suits your needs.
Submission
I would be happy to include methods created by others to this thread. If you have created a custom transition and would like to submit, please do so, using this template:
[hr]
[b][u][color=green]<NAME OF EFFECT>[/color][/u][/b]
[spoiler][quote]<CODE FOR THE METHOD GOES HERE, BUT USE CODE TAGS>[/quote][/spoiler]
<SMALL EXPLANATION OF WHAT IT DOES>
[list]
[*][b]<ARGUMENT1:>[/b] <EXPLAIN WHAT THE FIRST ARGUMENT DOES>
[*][b]<ARGUMENT2:>[/b] <EXPLAIN WHAT THE SECOND ARGUMENT DOES>
[*]<AND SO ON...>
[/list]
Tile Sprite Method
def tile_sprites(tilesize)
tiles = []
# Iterate through main sprite, creating sprites for each square.
(0...@sprite.bitmap.width / tilesize).each {|x|
(0...@sprite.bitmap.height / tilesize).each {|y|
sprite = Sprite.new
sprite.x, sprite.y = x*tilesize, y*tilesize
sprite.bitmap = Bitmap.new(tilesize, tilesize)
rect = Rect.new(sprite.x, sprite.y, tilesize, tilesize)
sprite.bitmap.blt(0, 0, @sprite.bitmap, rect)
tiles.push(sprite)
}
}
@sprite.opacity = 0
return tiles
end
This is not a transition, but is a required method for some of them. The transitions that require it will have a note stating that they do in the description.
Double Zoom
def double_zoom(frames = 30, zoom1 = 12, zoom2 = 32)
# Calculate the stages. Account for final zoom being longer.
stage3 = (frames * (zoom1.to_f / zoom2)).round
stages = [(frames - stage3) / 2, (frames - stage3) / 2, stage3]
# Calculate the zoom rates to apply each frame, for each stage.
zoom_rates, opacity_rate = [zoom1-1, -zoom1+1, zoom2], (255 / frames.to_f)
zoom_rates.each_index {|i| zoom_rates[i] /= stages[i].to_f }
# Initialize local variable to keep track of current stage being executed.
current_stage = 0
3.times do
# Iterate each stage, using the calculated rates for each one.
stages[current_stage].times do
@sprite.zoom_x += zoom_rates[current_stage]
@sprite.zoom_y += zoom_rates[current_stage]
@sprite.opacity -= opacity_rate
Graphics.update
end
current_stage += 1
end
end
Zooms in, then back out, then in again. Both zoom levels are configurable.
- FRAMES: Total number of frames the transition will take.
- ZOOM1: The target zoom level of the first zoom.
- ZOOM2: The target zoom of the second zoom.
Retro Final Fantasy
def ff_IV_style(zoom1 = 1.2, zoom2 = 32)
# Set number of frames and zoom rates for each stage.
stages = [4, 4, 4, 4, 20]
zooms = [zoom1, -zoom1, zoom1, -zoom1, zoom2]
zooms.each_index {|i| zooms[i] /= stages[i].to_f }
current_stage = 0
5.times do
# Begin processing.
stages[current_stage].times do
@sprite.zoom_x += zooms[current_stage]
@sprite.zoom_y += zooms[current_stage]
@sprite.opacity -= 12 if current_stage == 4
Graphics.update
end
# Increase current stage.
current_stage += 1
end
end
Classic transition used in early SNES Final Fantasy games. Similiar to the double zoom, does a quick double stammer, then zooms in all the way very quickly.
- ZOOM1: Level of zoom used in the initial stutter.
- ZOOM2: Level of zoom for the final zoom.
Downward Spiral
def downward_spiral(frames = 40, rotation_speed = 15)
# Calculate the zoom to subtract each frame.
zoom, opacity = 1.0 / frames, 128.0 / frames
frames.times do
# Begin processing.
@sprite.zoom_x -= zoom
@sprite.zoom_y -= zoom
@sprite.opacity -= opacity
@sprite.angle += rotation_speed
Graphics.update
end
end
Screen rotates as it falls fading away.
- FRAMES: Total number of frames the transition takes to fall away completely.
- ROTATION SPEED: Defines how fast the screen rotates in degrees.
Blackhole
def blackhole(speed = 4, tilesize = 12, source = [320, 240])
# Initialize squares array to hold each sprite.
tiles = tile_sprites(tilesize)
# Make each sprite slightly smaller than full size.
tiles.each {|tile| tile.zoom_x = tile.zoom_y = 0.85 }
# Begin looping until all sprites have been disposed.
until tiles.compact == []
# Iterate each tiles.
tiles.each_index {|i|
next if tiles[i] == nil
# Get distance of this sprite from the source for each axis.
sx = source[0] - tiles[i].x
sy = source[1] - tiles[i].y
# Calculate total distance and set base speed for each axis.
dist = Math.hypot(sx, sy).to_f
move_x = (dist / (sx == 0 ? 1 : sx))
move_y = (dist / (sy == 0 ? 1 : sy))
# Add a little randomness to the mix.
move_x += move_x < 0 ? -rand(speed) : rand(speed)
move_y += move_y < 0 ? -rand(speed) : rand(speed)
# Apply movement.
tiles[i].x += move_x
tiles[i].y += move_y
tiles[i].angle += rand(20)
# If tile is within its own size from source, dispose it.
if sx.abs <= tilesize && sy.abs <= tilesize
tiles[i].bitmap.dispose
tiles[i] = tiles[i].dispose
end
}
Graphics.update
end
end
Screen is broken into small pieces, which are then sucked into a specific point on the screen.
- SPEED: Defines how fast the pieces move to the SOURCE.
- TILESIZE: Size, in pixels, of the width and height that the tiles that the screen is broken into.
- SOURCE: A two element array that defines the X and Y, in pixels, of the origin point of the "blackhole".
REQUIRES "tile_sprite" METHOD. (see above)
Wave Distort
def wave_distort(frames = 60, direction = 2, power = 0.4)
radius, tiles = 0, tile_sprites(16)
# Define starting point for zoom, depending on direction.
origin = case direction
when 2 then [@sprite.bitmap.width / 2, @sprite.bitmap.height]
when 4 then [0, @sprite.bitmap.height / 2]
when 6 then [@sprite.bitmap.width, @sprite.bitmap.height / 2]
when 8 then [@sprite.bitmap.width / 2, 0]
end
# Initialize local variable for the rate the radius will increase.
rate = Math.hypot(@sprite.bitmap.width, @sprite.bitmap.height) / frames
# Begin processing.
frames.times do
# Iterate through each tile, calculating distance from focal point.
tiles.each {|tile|
dist = Math.hypot((origin[0] - tile.x), (origin[1] - tile.y))
# Zoom tile on one axis, depending on direction.
next if radius < dist
[4, 6].include?(direction) ? tile.zoom_x += power : tile.zoom_y += power
}
# Increase radius for next iteration.
radius += rate
Graphics.update
end
# Dispose each bitmap and sprite used for the tiles.
tiles.each {|tile| tile.bitmap.dispose; tile.dispose }
end
Causes the screen to distort in a "wave" effect.
- FRAMES: Total number of frames the transition will take.
- DIRECTION: Corresponds to the direction the wave comes from. (2 = down, 4 = left, 6 = right, 8 = up)
- POWER: The level of the distort. Should be a small number between 0 and 1.
REQUIRES "tile_sprite" METHOD. (see above)
Radial Break
def radial_break(frames = 60, tilesize = 16, direction = 4, speed = 9)
radius, tiles = 0, tile_sprites(tilesize)
# Define starting point for zoom, depending on direction.
origin = case direction
when 2 then [@sprite.bitmap.width / 2, @sprite.bitmap.height]
when 4 then [0, @sprite.bitmap.height / 2]
when 6 then [@sprite.bitmap.width, @sprite.bitmap.height / 2]
when 8 then [@sprite.bitmap.width / 2, 0]
end
# Initialize local variable for the rate the radius will increase.
rate = Math.hypot(@sprite.bitmap.width, @sprite.bitmap.height) / frames
# Begin processing.
until tiles == []
tiles.compact!
# Iterate through each tile, calculating distance from focal point.
tiles.each_index {|i|
# Get distance of this sprite from the source for each axis.
sx = origin[0] - tiles[i].x
sy = origin[1] - tiles[i].y
dist = Math.hypot(sx, sy).to_f
# Zoom tile on one axis, depending on direction.
next if radius < dist
# Calculate total distance and set base speed for each axis.
move_x = (dist / (sx == 0 ? 1 : sx))
move_y = (dist / (sy == 0 ? 1 : sy))
# Add a little randomness to the mix.
move_x += move_x < 0 ? -rand(speed) : rand(speed)
move_y += move_y < 0 ? -rand(speed) : rand(speed)
# Half distance of one axis, depending on rate.
[2, 8].include?(direction) ? move_x /= 2 : move_y /= 2
# Apply movement.
tiles[i].x += move_x
tiles[i].y += move_y
angle = (tiles[i].object_id % 2 == 0) ? rand(25) : -rand(25)
tiles[i].angle += (angle + 5)
# If tile is within its own size from source, dispose it.
if sx.abs <= tilesize || sy.abs <= tilesize
tiles[i].bitmap.dispose
tiles[i] = tiles[i].dispose
end
}
# Increase radius for next iteration.
radius += rate / 2
Graphics.update
end
end
Screen breaks into hundreds of pieces in a wave effect, and then move towards the source of the wave in a random pattern.
- FRAMES: Number of frames the transition will take. (approx.)
- TILESIZE: Size, in pixels, of the width and height that the tiles that the screen is broken into.
- DIRECTION: Corresponds to the direction the wave comes from. (2 = down, 4 = left, 6 = right, 8 = up)
- SPEED: Speed at which the pieces move.
REQUIRES "tile_sprite" METHOD. (see above)