Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Fading Pictures script

Nachos

Sponsor

Pictures fading script

This scrip shows an image fading it in, showing it for a few seconds, and the fading it off.

-Doesn't use SDK.
-Has no other fancy functions
-It is compatible with almost everything


Compatibility:

-No errors found.

Usage:

Code:
$Game_FadingPics.fade("picName" [, x][, y][, zoom_x][, zoom_y][, orgin])

"[, x][, y][, zoom_x][, zoom_y][, orgin]" optional.

Credits:
-Brewmeister for the comments.
-EOG for clearing some doubts and clearing the script out.


Script:


Paste above main

Code:
#==============================================================================
#   â–  Pictures fading
#==============================================================================
#   By: Nahchito & EOG (rmxp) / www.nachosonline.tk
#   Date: 30/12/2008
#   Version: V 0.1
#==============================================================================

class Game_FadingPics
#==============================================================================
# ** Initialize
#==============================================================================
  def initialize
    @fadeing_in = []
    for picture in $game_screen.pictures
      if picture == nil
        next
      end
      @fadeing_in[picture.number] = false
    end #if
  end #def
#==============================================================================
# ** Fade
#==============================================================================
  def fade(picName , x = 0, y = 0, zoom_x = 100, zoom_y = 100, orgin = 0)
    if $scene.is_a?(Scene_Map)
      for picture in $game_screen.pictures
        if picture == nil
          next
        end
        if picture.erased? #find empty picture
          $game_screen.pictures[picture.number].show(picName, orgin, x, y, zoom_x, zoom_y, 0, 0)
          @fadeing_in[picture.number] = true
          break
        end #if
      end #for
    end #if
  end #def
 #--------------------------------------------------------------------------
 # ** Update
 #-------------------------------------------------------------------------- 
  def update
    #fadeing
    for picture in $game_screen.pictures
      if picture == nil
        next
      end
      if @fadeing_in[picture.number]
        picture.opacity += 1
        if picture.opacity == 255
          @fadeing_in[picture.number] = false
        end #if
      end #if
      if !@fadeing_in[picture.number] and picture.erased? != ""
        picture.opacity -= 1
        if picture.opacity == 0
          picture.erase
        end #if
      end #if
    end #for
  end #def
end #class
  
class Scene_Map
    alias old_main main
    alias old_update update
    def main
      $Game_FadingPics = Game_FadingPics.new
      old_main
    end 
    def update
      old_update
      $Game_FadingPics.update
    end
  end
class Game_Picture
  attr_accessor :opacity
  def erased?
    if @name == ""
      return true
    end
    return false
  end
end

Be well
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top