Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # ASR exclusive script - Call Picture
- # Author : TheoAllen
- # =============================================================================
- =begin
- Penggunaan dan Script call :
- Masukkan gambar yg mau dipanggil di Graphics/picture
- Gunain script call kek gini
- call_picture("nama", pos, flip, effect)
- - nama >> nama file gambar
- - pos >> pilih salah satu antara :A (kiri) dan :B (kanan)
- - flip >> true/false. jika tidak diisi, maka defaultnya false
- - effect >> effect yg mo ditampilin (listnya ada dibawah)
- clear_pictures
- ngilangin semua picture
- remove_pic(pos)
- ngilangin picture di posisi tertentu (:A ato :B)
- -----------------------------------------------------------------------------
- Effects List
- -----------------------------------------------------------------------------
- - fadein(durasi) >> Bikin effect fadein dengan durasi tertentu
- - fadeout(durasi) >> Bikin effect fadeout dengan durasi tertentu
- - scroll_in(durasi) >> Bikin effect scroll masuk dengan durasi tertentu
- - scroll_out(durasi) >> Bikin effect scroll keluar dengan durasi tertentu
- - opacity(nilai) >> Ngubah opacity gambar (0 - 255)
- - pic_tone(r,g,b,gray) >> Ngubah tone / tint gambar.
- Contoh penggunaan dalam call picture :
- call_picture("name", :A, false, fadein(10), scroll_in(10))
- Kalo pengen langsung, bisa dengan gunain :
- pic_effect(:A, scroll_out(10))
- Note :
- Effect bisa dimasukin dua atau lebih
- =end
- # =============================================================================
- # Do not touch anything pass this line
- # =============================================================================
- module Effects
- Fadein = 1
- Fadeout = 2
- Scroll_in = 3
- Scroll_out = 4
- PicTone = 5
- Opacity = 6
- end
- class EffData
- attr_accessor :eff_id
- attr_accessor :param
- def initialize
- @eff_id = 0
- @param = 0
- end
- end
- class Game_Interpreter
- A = :A
- B = :B
- include Effects
- def call_picture(picname, pos, flip = false, *args)
- return unless SceneManager.scene_is?(Scene_Map)
- pos = :B unless pos.is_a?(Symbol) && pos == :A
- picture = SceneManager.scene.getpic(pos)
- unless picture
- bitmap = Cache.picture(picname)
- picture = Picture.new(bitmap,pos)
- picture.mirror = flip
- SceneManager.scene.add_picture(picture, pos)
- else
- picture.bitmap = Cache.picture(picname)
- picture.update_position
- picture.mirror = flip
- end
- args.each do |eff|
- picture.start_effect(eff)
- end
- end
- def pic_effect(pos, *args)
- return unless SceneManager.scene_is?(Scene_Map)
- pos = :B unless pos.is_a?(Symbol) && pos == :A
- picture = SceneManager.scene.getpic(pos)
- return unless picture
- args.each do |eff|
- picture.start_effect(eff)
- end
- end
- def clear_pictures
- return unless SceneManager.scene_is?(Scene_Map)
- SceneManager.scene.clear_pictures
- end
- def remove_pic(pos)
- return unless SceneManager.scene_is?(Scene_Map)
- pos = :B unless pos.is_a?(Symbol) && pos == :A
- SceneManager.scene.remove_pic(pos)
- end
- def make_effect(eff_id, param)
- effect = EffData.new
- effect.eff_id = eff_id
- effect.param = param
- return effect
- end
- def fadein(duration)
- return make_effect(Fadein,duration)
- end
- def fadeout(duration)
- return make_effect(Fadeout,duration)
- end
- def scroll_in(duration)
- return make_effect(Scroll_in,duration)
- end
- def scroll_out(duration)
- return make_effect(Scroll_out,duration)
- end
- def pic_tone(r,g,b,gr = 0)
- tone = Tone.new(r,g,b,gr)
- return make_effect(PicTone,tone)
- end
- def opacity(value)
- return make_effect(Opacity,value)
- end
- end
- class Picture < Sprite_Base
- attr_accessor :pos
- attr_accessor :max_opacity
- include Effects
- def initialize(bitmap,pos)
- super(nil)
- self.max_opacity = 255
- self.bitmap = bitmap
- self.pos = pos
- update_anchor
- update_position
- end
- def update_anchor
- self.oy = height
- self.ox = width/2
- end
- def update_position
- self.y = Graphics.height
- if pos == :A
- self.x = width/2
- else
- self.x = Graphics.width - width/2
- end
- end
- def hide_position
- self.y = Graphics.height
- if pos == :A
- self.x = 0 - width/2
- else
- self.x = Graphics.width + width/2
- end
- end
- def start_effect(effect)
- effect_table[effect.eff_id].call(effect.param)
- end
- def effect_table
- hash = {
- Fadein => method(:start_fadein),
- Fadeout => method(:start_fadeout),
- Scroll_in => method(:scroll_in),
- Scroll_out => method(:scroll_out),
- PicTone => method(:tone_change),
- Opacity => method(:change_opacity),
- }
- return hash
- end
- def start_fadein(duration)
- self.opacity = 0
- self.fade(max_opacity, duration)
- end
- def start_fadeout(duration)
- self.opacity = max_opacity
- self.fadeout(duration)
- end
- def scroll_in(duration)
- hide_position
- if pos == :A
- right(width,duration)
- else
- left(width,duration)
- end
- end
- def scroll_out(duration)
- update_position
- if pos == :A
- left(width,duration)
- else
- right(width,duration)
- end
- end
- def tone_change(tone)
- self.tone = tone
- end
- def change_opacity(value)
- self.opacity = self.max_opacity = value
- end
- end
- class Scene_Map < Scene_Base
- alias asr_callpic_start start
- def start
- asr_callpic_start
- @called_pic = {}
- end
- def getpic(pos)
- @called_pic[pos]
- end
- def add_picture(sprite, pos)
- @called_pic[pos] = sprite
- end
- def clear_pictures
- dispose_pics
- @called_pic.clear
- end
- def remove_pic(pos)
- @called_pic[pos].dispose
- @called_pic.delete(pos)
- end
- def dispose_pics
- @called_pic.values.each do |pic|
- pic.dispose if pic
- end
- end
- alias asr_callpic_update update
- def update
- asr_callpic_update
- update_pics
- end
- def update_pics
- @called_pic.values.each {|pic| pic.update }
- end
- alias asr_callpic_terminate terminate
- def terminate
- asr_callpic_terminate
- dispose_pics
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment