Help - Search - Members - Calendar
Full Version: fading pictures in and right out again
RPG RPG Revolution Forums > Scripting > Script Development and Support > RGSS3
j-frost
Hello everybody,

I'm currently working on a Final Fantasy Tactics / Fire Emblem / Advance Wars like game. To implement the different phases (chiefly selection, player and enemy phases), I need to notify the player of the transition between the phases. To do this, I want to show a picture at 0 opacity, fade it in via move, wait 90 seconds, and fade it out again. I have so far implemented this successfully by putting an autorun event on the map. Now I wanted to transition to a script based approach, but I have not been able to get it to work.

So far, I have tried the following:
CODE
$game_map.screen.pictures[1].make(@phase)
20.times { Graphics.update }
$game_map.screen.pictures[1].fade_in
90.times { Graphics.update }
$game_map.screen.pictures[1].fade_out


with an extension to Game_Picture as follows:

CODE
# make simpler calls to pictures

class Game_Picture
  
  def make(phase)
    phase[0] = phase[0].capitalize[0]
    banner = phase + 'PhaseBanner'
    @name = banner
    @blend_type = 0
    @opacity = 0
  end
  
  def fade_in
    @target_opacity = 255
    @duration = 30
  end
  
  def fade_out
    @target_opacity = 0
    @duration = 60
  end
  
end


The above code does not work correctly. It does not cause a fade in animation; instead, the picture's opacity remains 0 until the fading out starts. I've tried using different wait methods and even threading the fading away from the main program as such:

CODE
$game_map.screen.pictures[1].make(@phase)
thread = Thread.new {
   $game_map.screen.pictures[1].fade_in
   sleep(3)
   $game_map.screen.pictures[1].fade_out
}
thread.join


I'm at a loss here as to what I might have overlooked.

Regards,

j-frost
Jens of Zanicuud
Have you tried this configuration? If you don't update the map process, the opacity will never fade away, since there would be nobody to say the program what to do while the cycle goes through the Graphics updates...
Just add a $game_map.screen.pictures[1].update to update the picture's variables (opacity, wait time, et cetera) and a SceneManager.scene.update to update the Spriteset and that should work. I can't assure you a 100% rate of success, since I'm more RGSS - RGSS2 oriented, but this could surely be the problem.

CODE
$game_map.screen.pictures[1].make(@phase)
20.times { Graphics.update
$game_map.screen.pictures[1].update
SceneManager.scene.update
}
$game_map.screen.pictures[1].fade_in
90.times { Graphics.update
$game_map.screen.pictures[1].update
SceneManager.scene.update
}
$game_map.screen.pictures[1].fade_out


I hope this can help,

Jens
j-frost
QUOTE (Jens of Zanicuud @ Jan 20 2013, 01:03 PM) *
Just add a $game_map.screen.pictures[1].update to update the picture's variables (opacity, wait time, et cetera) and a SceneManager.scene.update to update the Spriteset and that should work.

Thank you so much!! Updating the scene is actually exactly what I forgot to do, which caused it to optimize my code and jump to the next line of code after setting the variables in my Game_Picture.

For future reference:

Solution
CODE
$game_map.screen.pictures[1].make(@phase)
20.times { SceneManager.scene.update }
$game_map.screen.pictures[1].fade_in
90.times { SceneManager.scene.update }
$game_map.screen.pictures[1].fade_out
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2013 Invision Power Services, Inc.