• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
Cinematic Fade In/Out

Resource Cinematic Fade In/Out 2021-06-09

TechSkylander1518 submitted a new resource:

Cinematic Fade In/Out - A semi-fancy version of the usual fade in/out when transferring maps!

View attachment 4651
Okay I should have made a nicer map but I didn't want to go out of my way for a demo GIF

This is a script that shows the player character fading into a black screen when transitioning from one map to another!

Code
Ruby:
Expand Collapse Copy
#Fade Speed is how fast the player sprite and screen fade out
FADE_SPEED = 15


#I know this is grossly inefficient, but I don't know a better way to do it atm
def prePlayer...

Read more about this resource...
 

Leondrea

Trainer
Member
Joined
Jul 26, 2020
Posts
95
Shouldn't the player be invisible, when the screen turns black?
This way, it looks like the character is inside the black screen.
It looks weird to me, but idk if this is on purpose.
Maybe its just me, idk...
 
Shouldn't the player be invisible, when the screen turns black?
This way, it looks like the character is inside the black screen.
It looks weird to me, but idk if this is on purpose.
Maybe its just me, idk...
That's how it was requested, but it's easy to change like to work like that as well!

Delete the line
Ruby:
Expand Collapse Copy
preplayer *= 2

Change this section

Ruby:
Expand Collapse Copy
    loop do
      if @sprite.opacity >= 255
        break
      else
        @sprite.opacity += FADE_SPEED
        dummyMove
        @player.update
        Graphics.update
      end
    end
    10.times do
      @player.update
    end
    loop do
      if @player.opacity <= 0
        break
      else
        @player.opacity -= FADE_SPEED
        dummyMove
        Graphics.update
      end
    end

to

Ruby:
Expand Collapse Copy
    loop do
      if @sprite.opacity >= 255
        break
      else
        @sprite.opacity += FADE_SPEED
        @player.opacity -= FADE_SPEED
        dummyMove
        @player.update
        Graphics.update
      end
    end

And change this section

Ruby:
Expand Collapse Copy
   loop do
      if @player.opacity >= 255
        break
      else
        @player.opacity += FADE_SPEED
        @player.update
        dummyMove
        Graphics.update
      end
    end
    loop do
      if @sprite.opacity <= 0
        break
      else
        @sprite.opacity -= FADE_SPEED
        dummyMove
        @player.update
        Graphics.update
      end
    end

to

Ruby:
Expand Collapse Copy
   loop do
      if @player.opacity >= 255
        break
      else
        @player.opacity += FADE_SPEED
        @sprite.opacity -= FADE_SPEED
        @player.update
        dummyMove
        Graphics.update
      end
    end
 

lavendersiren

Mage of Light
Member
Joined
Apr 17, 2023
Posts
9
I decided to try and make this work in 20.1 today.
It took all day to figure out how things had changed between v19 and v20.1, but I figure this is decent scripting practice.

Ruby:
Expand Collapse Copy
# -----------------------------
# Cinematic Fade In/Out 1.2 - by TechSkylander1518 , updated to work in 20.1 by lavendersiren
#
# -----------------------------------
# How to use:
# stick this in a scriptlet and edit the values as needed.
# cinTransition(mapid,x,y,dir=nil) (dir is optional, uses numpad notation)
# cinFadeOut or cinFadeIn can also be used instead if you just want the transition lead in/lead out applied separately.
# ---------------------------------

#Fade Speed is how fast the player sprite and screen fade out
FADE_SPEED = 15

class TrainerWalkingCharSprite < SpriteWrapper
  def direction=(value)
    @direction = value
    self.src_rect.y = @animbitmap.bitmap.height/4*@direction
  end
end

def dummyMove
  return if !$game_temp.cin_player
  case $game_player.direction
  when 2
    $game_temp.cin_player.y += 1
    $game_map.display_y += 5
    pbUpdateSceneMap
    $game_temp.cin_player.update
    Graphics.update
  when 4
    $game_temp.cin_player.x -= 1
    $game_map.display_x -= 5
    pbUpdateSceneMap
    $game_temp.cin_player.update
    Graphics.update
  when 6
    $game_temp.cin_player.x += 1
    $game_map.display_x += 5
    pbUpdateSceneMap
    $game_temp.cin_player.update
    Graphics.update
  when 8
    $game_temp.cin_player.y -= 1
    $game_map.display_y -= 5
    pbUpdateSceneMap
    $game_temp.cin_player.update
    Graphics.update
  end
end

def cinFadeOut
  pbMoveRoute($game_player,[PBMoveRoute::Opacity,0],true)
  $game_player.transparent = true
  pbWait(1)
  $game_temp.cin_viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
  $game_temp.cin_viewport.z = 99998
  meta = GameData::PlayerMetadata.get($player.character_ID) #meta = GameData::Metadata.get_player($player.character_ID)
  filename = pbGetPlayerCharset(meta.walk_charset,nil,true) #pbGetPlayerCharset(meta,1,nil,true)
  $game_temp.cin_player = TrainerWalkingCharSprite.new(filename,$game_temp.cin_viewport)
  #need to figure out how to grab the player sprite from file name
  $game_temp.cin_player.animspeed = $game_player.move_speed * 3
  charwidth = $game_temp.cin_player.bitmap.width
  charheight = $game_temp.cin_player.bitmap.height
  $game_temp.cin_player.ox = charwidth/8
  $game_temp.cin_player.oy = charheight/8
  $game_temp.cin_player.x = (Graphics.width/2)
  $game_temp.cin_player.y = (Graphics.height/2) - 8
  pbDayNightTint($game_temp.cin_player)
  case $game_player.direction
  when 2
    $game_temp.cin_player.direction = 0
  when 4
    $game_temp.cin_player.direction = 1
  when 6
    $game_temp.cin_player.direction = 2
  when 8
    $game_temp.cin_player.direction = 3
  end
  $game_temp.cin_player.update
  Graphics.update
  $game_temp.cin_bg = BitmapSprite.new(Graphics.width,Graphics.height,$game_temp.cin_viewport)
  $game_temp.cin_bg.bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0))
  $game_temp.cin_bg.opacity = 0
  $game_temp.cin_player.z = 99999
  loop do
    break if $game_temp.cin_bg.opacity >= 255
    $game_temp.cin_bg.opacity += FADE_SPEED
    dummyMove
    $game_temp.cin_player.update
    Graphics.update
  end
  10.times do
    $game_temp.cin_player.update
  end
  loop do
    break if $game_temp.cin_player.opacity <= 0
    $game_temp.cin_player.opacity -= FADE_SPEED
    dummyMove
    Graphics.update
  end
  $game_temp.cin_bg.dispose
  $game_temp.cin_bg = nil
  $game_temp.cin_player.dispose
  $game_temp.cin_player = nil
  $game_temp.cin_viewport.dispose
  $game_temp.cin_viewport = nil
  pbMoveRoute($game_player,[PBMoveRoute::Opacity,255],true)
  $game_player.transparent=false
  $game_map.update
end



def cinFadeIn
  $game_temp.cin_viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
  $game_temp.cin_viewport.z = 99998
  $game_temp.cin_bg = BitmapSprite.new(Graphics.width,Graphics.height,$game_temp.cin_viewport)
  $game_temp.cin_bg.bitmap.fill_rect(0,0,Graphics.width,Graphics.height,Color.new(0,0,0))
  pbMoveRoute($game_player,[PBMoveRoute::Opacity,0],true)
  $game_player.transparent = true
  pbWait(1)
  #and we do it here too
  meta = GameData::PlayerMetadata.get($player.character_ID) #meta = GameData::Metadata.get_player($player.character_ID)
  filename = pbGetPlayerCharset(meta.walk_charset,nil,true) #filename = pbGetPlayerCharset(meta,1,nil,true)
  $game_temp.cin_player = TrainerWalkingCharSprite.new(filename,$game_temp.cin_viewport)
  $game_temp.cin_player.animspeed = $game_player.move_speed * 3
  charwidth = $game_temp.cin_player.bitmap.width
  charheight = $game_temp.cin_player.bitmap.height
  $game_temp.cin_player.ox = charwidth/8
  $game_temp.cin_player.oy = charheight/8
  $game_temp.cin_player.x = (Graphics.width/2)
  $game_temp.cin_player.y = (Graphics.height/2) - 8
  pbDayNightTint($game_temp.cin_player)
  preplayer = (255/FADE_SPEED) * 2
  premap = (255/FADE_SPEED) * 10
  case $game_player.direction
  when 2
    $game_temp.cin_player.direction = 0
    $game_temp.cin_player.y -= preplayer
    $game_map.display_y -= premap
    pbUpdateSceneMap
  when 4
    $game_temp.cin_player.direction = 1
    $game_temp.cin_player.x += preplayer
    $game_map.display_x += premap
    pbUpdateSceneMap
  when 6
    $game_temp.cin_player.direction = 2
    $game_temp.cin_player.x -= preplayer
    $game_map.display_x -= premap
    pbUpdateSceneMap
  when 8
    $game_temp.cin_player.direction = 3
    $game_temp.cin_player.y += preplayer
    $game_map.display_y += premap
    pbUpdateSceneMap
  end
  $game_temp.cin_player.z = 99999
  $game_temp.cin_player.opacity = 0
  loop do
    break if $game_temp.cin_player.opacity >= 255
    $game_temp.cin_player.opacity += FADE_SPEED
    $game_temp.cin_player.update
    dummyMove
    Graphics.update
  end
  loop do
    break if $game_temp.cin_bg.opacity <= 0
    $game_temp.cin_bg.opacity -= FADE_SPEED
    dummyMove
    $game_temp.cin_player.update
    Graphics.update
  end
  $game_temp.cin_bg.dispose
  $game_temp.cin_bg = nil
  $game_temp.cin_player.dispose
  $game_temp.cin_player = nil
  $game_temp.cin_viewport.dispose
  $game_temp.cin_viewport = nil
  pbMoveRoute($game_player,[PBMoveRoute::Opacity,255],true)
  $game_player.transparent = false
  $game_map.update
end

def cinTransition(mapid,x,y,dir=nil)
  cinFadeOut
  case dir
  when nil,"retain","Retain","0"
    dir = 0
  when "2","up","Up"
    dir = 2
  when "4","left","Left"
    dir = 4
  when "6","right","Right"
    dir = 6
  when "8","down","Down"
    dir = 8
  end
  $game_temp.player_new_map_id    = mapid
  $game_temp.player_new_x         = x
  $game_temp.player_new_y         = y
  $game_temp.player_new_direction = dir
  $scene.transfer_player
  $game_map.autoplay
  $game_map.refresh
  cinFadeIn
end

class Game_Temp
  attr_accessor :cin_player
  attr_accessor :cin_bg
  attr_accessor :cin_viewport
end

EDIT: fixed name typo
 
Last edited:

lavendersiren

Mage of Light
Member
Joined
Apr 17, 2023
Posts
9
aaaand I just realized I typo'd my name. <@ _@> (its lavendersiren, not lavendersioren)
Also no problem. I feel its important to share resources like this with the community.
 

Cryptochrome

Heretic
Member
Joined
Dec 4, 2019
Posts
55
Using the suggested v18 changes gives me a NameError.

Instead changed:
Ruby:
Expand Collapse Copy
meta = GameData::Metadata.get_player($Trainer.character_ID)
to:
Ruby:
Expand Collapse Copy
trainer = $Trainer if !trainer   
meta = pbGetMetadata(0,MetadataPlayerA+trainer.metaID)

I'm relatively new to coding, so... apologies if this causes errors elsewhere. I copied the additional line from another script section. However the script is working for me now.
 
Back
Top