TheoAllen

Theo - Splash Screen

May 1st, 2013
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.72 KB | None | 0 0
  1. # =============================================================================
  2. # THEOALLEN - SPLASH SCREEN
  3. # VERSION : 1.0
  4. # CONTACT : www.rpgmakerid.com
  5. # (This script documentation is written in informal indonesian language)
  6. # =============================================================================
  7. $imported = {} if $imported.nil?
  8. $imported[:Theo_Splash] = true
  9. # =============================================================================
  10. =begin
  11.  
  12.   PENGENALAN :
  13.   Script ini untuk bikin splash screen sebelum title
  14.  
  15.   CARA PAKAI :
  16.   Taruh script ini di atas main dan dibawah materials.
  17.   Pastikan gambar2 yang nantinya u pake buat splash screen ditaruh di folder
  18.   Graphics/picture
  19.  
  20.   TERMS OF USE :
  21.   Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
  22.   keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
  23.   dipake buat komersil, jangan lupa, gw dibagi gratisannya.
  24.  
  25. =end
  26. # =============================================================================
  27. # KONFIGURASI :
  28. # =============================================================================
  29. module THEO
  30.   module Splash
  31.    
  32.     SPLASH_BGM = "Theme2" # Nama file untuk lagu splash screen
  33.     BGM_VOLUME = 100      # Volume lagu
  34.     BGM_PITCH  = 100      # Pitch lagu
  35.    
  36.     SPLASH_ARRAY = [ # <-- Jangan dihapus
  37.    
  38.     # Atur banyaknya gambar yg muncul dalam splash screen disini
  39.     # Untuk fadein, wait, ama fadeout angka dalam satuan frame. Dalam artian,
  40.     # jika u tulis 60, maka waktu yg dibutuhkan = 1 detik
  41.    
  42.     # ["ImageName", fadein, wait, fadeout],
  43.       ["test"     ,     60,  120,      15],
  44.       ["test"     ,    120,  120,      10],
  45.    
  46.     # Tambahin sendiri  
  47.     ] # <-- Jangan dihapus
  48.    
  49.   end
  50. end
  51. # =============================================================================
  52. if true # <-- untuk nge-disable, ganti true dengan false
  53. # -----------------------------------------------------------------------------
  54. # Batas akhir konfigurasi. Jangan diedit setelah line ini kecuali ente ngerti
  55. # =============================================================================
  56. class Splash_Screen < Scene_Base # class untuk splash screen
  57.   # ---------------------------------------------------------------------------
  58.   # Starting Scene
  59.   # ---------------------------------------------------------------------------
  60.   def start
  61.     super
  62.     @count = 0          # hitungan frame
  63.     @stage = 0          # stage gambar
  64.     @fadein = 0.0       # kecepatan fadein
  65.     @fadeout = 0.0      # kecepatan fadeout
  66.     create_image_arrays
  67.     play_bgm
  68.     determine_fade_speed
  69.   end
  70.   # ---------------------------------------------------------------------------
  71.   # Bikin array gambar2 splash screen
  72.   # ---------------------------------------------------------------------------
  73.   def create_image_arrays
  74.     @images = []
  75.     splash_arrays.each do |splash|
  76.       img = Sprite.new(@viewport)
  77.       img.bitmap = Cache.picture(splash[0])
  78.       img.opacity = 0
  79.       @images.push(img)
  80.     end
  81.   end
  82.   # ---------------------------------------------------------------------------
  83.   # Nentuin kecepatan fade
  84.   # ---------------------------------------------------------------------------
  85.   def determine_fade_speed
  86.     @fadein = 255 / splash_arrays[@stage][1].to_f
  87.     @fadeout = 255 / splash_arrays[@stage][3]
  88.   end
  89.   # ---------------------------------------------------------------------------
  90.   # Puter musik splash screen
  91.   # ---------------------------------------------------------------------------
  92.   def play_bgm
  93.     name = sprintf("Audio/BGM/%s",THEO::Splash::SPLASH_BGM)
  94.     vol = THEO::Splash::BGM_VOLUME
  95.     pitch = THEO::Splash::BGM_PITCH
  96.     Audio.bgm_play(name,vol,pitch)
  97.   end
  98.   # ---------------------------------------------------------------------------
  99.   # Ambil array splash screen dari modul
  100.   # ---------------------------------------------------------------------------
  101.   def splash_arrays
  102.     THEO::Splash::SPLASH_ARRAY
  103.   end
  104.   # ---------------------------------------------------------------------------
  105.   # Update per frame
  106.   # ---------------------------------------------------------------------------
  107.   def update
  108.     super
  109.     @count += 1
  110.     update_image
  111.     if @count % max_duration == 0
  112.       @images[@stage].dispose
  113.       @count = 0
  114.       @stage += 1
  115.       if exit?
  116.         exit_splash_screen
  117.         return
  118.       end
  119.       determine_fade_speed
  120.     end
  121.   end
  122.   # ---------------------------------------------------------------------------
  123.   # Update opacity gambar
  124.   # ---------------------------------------------------------------------------
  125.   def update_image
  126.     ary = splash_arrays[@stage]
  127.     @images[@stage].opacity += @fadein.round if @count <= ary[1] && @images[@stage].opacity < 255
  128.     @images[@stage].opacity -= @fadeout.round if @count > ary[1] + ary[2] && @images[@stage].opacity > 0
  129.   end
  130.   # ---------------------------------------------------------------------------
  131.   # Masuk title screen
  132.   # ---------------------------------------------------------------------------
  133.   def exit_splash_screen
  134.     SceneManager.goto(Scene_Title)
  135.   end
  136.   # ---------------------------------------------------------------------------
  137.   # Syarat exit
  138.   # ---------------------------------------------------------------------------
  139.   def exit?
  140.     @stage >= stage_max
  141.   end
  142.   # ---------------------------------------------------------------------------
  143.   # Maksimum durasi satu gambar
  144.   # ---------------------------------------------------------------------------
  145.   def max_duration
  146.     ary = splash_arrays[@stage]
  147.     return ary[1] + ary[2] + ary[3]
  148.   end
  149.   # ---------------------------------------------------------------------------
  150.   # Stage maksimal (panjang array gambar splash screen)
  151.   # ---------------------------------------------------------------------------
  152.   def stage_max
  153.     splash_arrays.size
  154.   end
  155.  
  156. end
  157. # =============================================================================
  158. # Module SceneManager
  159. # =============================================================================
  160. module SceneManager
  161.   # ---------------------------------------------------------------------------
  162.   # Overwrite : Class Scene Pertama
  163.   # ---------------------------------------------------------------------------
  164.   def self.first_scene_class
  165.     $BTEST ? Scene_Battle : Splash_Screen
  166.   end
  167.  
  168. end
  169. # =============================================================================
  170. end # <-- akhir dari disable state
  171. # =============================================================================
  172. #
  173. #                                END OF SCRIPT
  174. #
  175. # =============================================================================
Advertisement
Add Comment
Please, Sign In to add comment