Confira o Videos Épicos #45!
5 Respostas   438 Visualizações
0 Membros e 1 Visitante estão vendo este tópico.
=begin New Picture Properties with Calls v1.1.1 by PK8 Created: 4/12/2012 Modified: 6/12/2012 ────────────────────────────────────────────────────────────────────────────── ■ Author's Notes I wanted to work on letting game creators animate their pictures a little more through script calls. I noticed certain properties such as color, mirror, and wave were missing so I decided to add them in. ────────────────────────────────────────────────────────────────────────────── ■ Introduction This script adds new properties to Game_Picture such as Mirror, Color, and Wave while giving users new calls to play with. ────────────────────────────────────────────────────────────────────────────── ■ Features o Adds Color, Mirror, Wave Amplitude, Wave Length, and Wave Speed o New calls: color_change, color_*_change ────────────────────────────────────────────────────────────────────────────── ■ Usage * relative is a truth value that is optional to use in your script calls. Script call for changing a Game Picture's Color in frames: screen.pictures[id].color_change(Color.new(r,g,b,a), duration) r/g/b: Min: 0, Max: 255 | a: Min: 0, Max: 255 (Optional) | duration: Min: 0 Script call for changing a Game Picture's Red Color screen.pictures[id].color_red_change(red, duration, relative) red: Min: 0, Max: 255 | duration: Min: 0 Script call for changing a Game Picture's Green Color screen.pictures[id].color_green_change(green, duration, relative) green: Min: 0, Max: 255 | duration: Min: 0 Script call for changing a Game Picture's Blue Color screen.pictures[id].color_blue_change(blue, duration, relative) blue: Min: 0, Max: 255 | duration: Min: 0 Script call for changing a Game Picture's Alpha: screen.pictures[id].color_alpha_change(alpha, duration, relative) alpha: Min: 0, Max: 255 | duration: Min: 0 Script call for changing a Game Picture's Wave Amplitude: screen.pictures[id].wave_amp_change(wave_amp, duration, relative) wave_amp: Min: 0 | duration: Min: 0 Script calls for changing a Game Picture's Wave Length: screen.pictures[id].wave_length_change(wave_length, duration) wave_length: Min: 2 | duration: Min: 0 Script calls for changing a Game Picture's Wave Speed: screen.pictures[id].wave_speed_change(wave_speed, duration) wave_speed: Min: 0 | duration: Min: 0 New Script calls for modifying Game Picture properties. o color: screen.pictures[id].color = Color.new(r, g, b) * Alpha's an optional argument. If you're getting a FalseClass error because of this script call, add a return true at the end. o color.red: screen.pictures[id].color.red = value o color.green: screen.pictures[id].color.green = value o color.blue: screen.pictures[id].color.blue = value o color.alpha: screen.pictures[id].color.alpha = value * Min: 0, Max: 255 o mirror: screen.pictures[id].mirror = value * true: on, false: off o wave_amp: screen.pictures[id].wave_amp = value o wave_length: screen.pictures[id].wave_length = value * Min: 2 o wave_speed: screen.pictures[id].wave_speed = value ────────────────────────────────────────────────────────────────────────────── ■ Examples Fades in the Color Alpha to Game Picture 1's sprite in 20 frames. $game_screen.pictures[1].color_alpha_change(255, 20) Fades out the Color Alpha to Game Picture 1's sprite in 20 frames $game_screen.pictures[1].color_alpha_change(0, 20) Gives Game Picture 1 a white color. $game_screen.pictures[1].color.red = 255 $game_screen.pictures[1].color.green = 255 $game_screen.pictures[1].color.blue = 255 $game_screen.pictures[1].color.alpha = 255 ────────────────────────────────────────────────────────────────────────────── ■ Changelog (MM/DD/YYYY) v1 (04/12/2012): Initial release. v1.1 (04/15/2012): Adds new relative argument to all methods made. v1.1.1 (06/12/2012): Shortened the code, ditched AccessibleProps setting, and now users can use an Array (instead of a Tone) to the color_change call. ────────────────────────────────────────────────────────────────────────────── ■ Methods Aliased o Sprite_Picture.update o Game_Picture.initialize o Game_Picture.update =end#==============================================================================# ** Sprite_Picture#------------------------------------------------------------------------------# This sprite is used to display the picture.It observes the Game_Character# class and automatically changes sprite conditions.#==============================================================================class Sprite_Picture < Sprite #--------------------------------------------------------------------------- # * Alias Listings #--------------------------------------------------------------------------- alias_method(:pk8_npp_update, :update) unless method_defined?(:pk8_npp_update) #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update pk8_npp_update self.mirror = @picture.mirror self.color = @picture.color self.wave_amp = @picture.wave_amp self.wave_length = @picture.wave_length self.wave_speed = @picture.wave_speed endend#==============================================================================# ** Game_Picture#------------------------------------------------------------------------------# This class handles the picture. It's used within the Game_Screen class# ($game_screen).#==============================================================================class Game_Picture #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :color, :mirror, :wave_amp, :wave_length, :wave_speed, :color_target, :color_duration, :color_red_target, :color_red_duration, :color_green_target, :color_green_duration, :color_blue_target, :color_blue_duration, :color_alpha_target, :color_alpha_duration, :wave_amp_target, :wave_amp_duration, :wave_length_target, :wave_length_duration, :wave_speed_target, :wave_speed_duration #--------------------------------------------------------------------------- # * Alias Listings #--------------------------------------------------------------------------- unless method_defined?(:pk8_npp_initialize) alias_method(:pk8_npp_initialize, :initialize) end unless method_defined?(:pk8_npp_update) alias_method(:pk8_npp_update, :update) end #-------------------------------------------------------------------------- # * Object Initialization # number : picture number #-------------------------------------------------------------------------- def initialize(number) pk8_npp_initialize(number) @color = Color.new(0, 0, 0, 0) @mirror = false @wave_amp, @wave_length, @wave_speed = 0, 2, 360 @color_target, @color_duration = Color.new(0, 0, 0, 0), 0 @color_red_target, @color_red_duration = 0, 0 @color_green_target, @color_green_duration = 0, 0 @color_blue_target, @color_blue_duration = 0, 0 @color_alpha_target, @color_alpha_duration = 0, 0 @wave_amp_target, @wave_amp_duration = 0, 0 @wave_length_target, @wave_length_duration = 2, 0 @wave_speed_target, @wave_speed_duration = 0, 0 end #-------------------------------------------------------------------------- # * Color Change # color : Target Color. (Color.new(red, green, blue[, alpha)) # duration : Frame amount. # relative : References current value and adds to it, if true. #-------------------------------------------------------------------------- def color_change(color, duration, relative = false) color = Color.new(*color) if color.is_a?(Array) if relative == true color.red = @color.red + color.red color.green = @color.green + color.green color.blue = @color.blue + color.blue color.alpha = @color.alpha + color.alpha end @color_target = color.clone @color_duration = duration @color = @color_target.clone if @color_duration == 0 end #-------------------------------------------------------------------------- # * Color Red Change # color_red : Target Red Color. (0 - 255) # duration : Frame amount. # relative : References current value and adds to it, if true. #-------------------------------------------------------------------------- def color_red_change(color_red, duration, relative = false) @color_red_target = (relative == true ? @color.red + color_red : color_red) @color_red_duration = duration @color.red = @color_red_target.clone if @color_red_duration == 0 end #-------------------------------------------------------------------------- # * Color Green Change # color_green : Target Green Color. (0 - 255) # duration : Frame amount. # relative : References current value and adds to it, if true. #-------------------------------------------------------------------------- def color_green_change(color_green, duration, relative = false) @color_green_target=(relative==true ?@color.green+color_green : color_green) @color_green_duration = duration @color.green = @color_green_target.clone if @color_green_duration == 0 end #-------------------------------------------------------------------------- # * Color Blue Change # color_blue : Target Blue Color. (0 - 255) # duration : Frame amount. # relative : References current value and adds to it, if true. #-------------------------------------------------------------------------- def color_blue_change(color_blue, duration, relative = false) @color_blue_target = (relative==true ? @color.blue+color_blue : color_blue) @color_blue_duration = duration @color.blue = @color_blue_target.clone if @color_blue_duration == 0 end #-------------------------------------------------------------------------- # * Color Alpha Change # color_alpha : Target Alpha. (0 - 255) # duration : Frame amount. # relative : References current value and adds to it, if true. #-------------------------------------------------------------------------- def color_alpha_change(color_alpha, duration, relative = false) @color_alpha_target=(relative==true ?@color.alpha+color_alpha : color_alpha) @color_alpha_duration = duration @color.alpha = @color_alpha_target.clone if @color_alpha_duration == 0 end #-------------------------------------------------------------------------- # * Wave Amplitude Change # wave_amp : Target Wave Amplitude. (0 > ) # duration : Frame amount. # relative : References current value and adds to it, if true. #-------------------------------------------------------------------------- def wave_amp_change(wave_amp, duration, relative = false) @wave_amp_target = (relative == true ? @wave_amp + wave_amp : wave_amp) @wave_amp_duration = duration @wave_amp = @wave_amp_target.clone if @wave_amp_duration == 0 end #-------------------------------------------------------------------------- # * Wave Length Change # wave_length : Target Wave Length. (2 > ) # duration : Frame amount. # relative : References current value and adds to it, if true. #-------------------------------------------------------------------------- def wave_length_change(wave_length, duration, relative = false) @wave_length_target=(relative==true ?@wave_length+wave_length : wave_length) @wave_length_target = 2 if @wave_length_target < 2 @wave_length_duration = duration @wave_length = @wave_length_target.clone if @wave_length_duration == 0 end #-------------------------------------------------------------------------- # * Wave Speed Change # wave_speed : Target Wave Speed. (0 > ) # duration : Frame amount. # relative : References current value and adds to it, if true. #-------------------------------------------------------------------------- def wave_speed_change(wave_speed, duration, relative = false) @wave_speed_target = (relative==true ? @wave_speed+wave_speed : wave_speed) @wave_speed_duration = duration @wave_speed = @wave_speed_target.clone if @wave_speed_duration == 0 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update pk8_npp_update if @color_duration >= 1 d = @color_duration @color.red = (@color.red * (d - 1) + @color_target.red) / d @color.green = (@color.green * (d - 1) + @color_target.green) / d @color.blue = (@color.blue * (d - 1) + @color_target.blue) / d @color.alpha = (@color.alpha * (d - 1) + @color_target.alpha) / d @color_duration -= 1 end if @color_red_duration >= 1 # Red color d = @color_red_duration @color.red = (@color.red * (d - 1) + @color_red_target) / d @color_red_duration -= 1 end if @color_green_duration >= 1 # Green color d = @color_green_duration @color.green = (@color.green * (d - 1) + @color_green_target) / d @color_green_duration -= 1 end if @color_blue_duration >= 1 # Blue color d = @color_blue_duration @color.blue = (@color.blue * (d - 1) + @color_blue_target) / d @color_blue_duration -= 1 end if @color_alpha_duration >= 1 # Alpha d = @color_alpha_duration @color.alpha = (@color.alpha * (d - 1) + @color_alpha_target) / d @color_alpha_duration -= 1 end if @wave_amp_duration >= 1 # Wave Amplitude d = @wave_amp_duration @wave_amp = (@wave_amp * (d - 1) + @wave_amp_target) / d @wave_amp_duration -= 1 end if @wave_length_duration >= 1 # Wave Length d = @wave_length_duration @wave_length = (@wave_length * (d - 1) + @wave_length_target) / d @wave_length_duration -= 1 end @wave_length = 2 if @wave_length < 2 if @wave_speed_duration >= 1 # Wave Speed d = @wave_speed_duration @wave_speed = (@wave_speed * (d - 1) + @wave_speed_target) / d @wave_speed_duration -= 1 end endend
#==============================================================================# • Animation Show Picture#==============================================================================# Autor: Dax# Versão: 1.0# Site: www.dax-soft.weebly.com# Requerimento:#==============================================================================# • Descrição:#------------------------------------------------------------------------------# Basicamente faz com que uma imagem seja executada em frames. Exemplo, você# usa o comando de Mostrar Imagem, aí você usa o call script é anima ela. Porém# a imagem deve estar nomeada com underline é o númerador do frame na frente, # exemplo: Img_1, Img_2.#==============================================================================# • Como usar: Chamar Script.#------------------------------------------------------------------------------# <• comando: > apicture(id, wait, last) : id -> id da imagem mostrada. # wait -> tempo de espera pra mudar de imagem.# last -> Última imagem do frame. Ponha o número do frame.# Exemplo:# apicture(1, 20, 3)#==============================================================================#==============================================================================# • Game_Temp#==============================================================================class Game_Temp attr_accessor :animate_show_pictureend#==============================================================================# • Game_Interpreter#==============================================================================class Game_Interpreter def apicture(id, wait, last) $game_temp.animate_show_picture = [id, wait, last] endend#==============================================================================# • Sprite_Picture#==============================================================================class Sprite_Picture < Sprite #-------------------------------------------------------------------------- # * Inicialização do objeto #-------------------------------------------------------------------------- def initialize(viewport, picture) super(viewport) @picture = picture unless $game_temp.animate_show_picture.nil? or $game_temp.animate_show_picture[0] != @picture.number.to_i @index = @picture.name.split(/_/)[2].to_i @max = $game_temp.animate_show_picture[2] @count = @wait = $game_temp.animate_show_picture[1] self.bitmap = Cache.picture(@picture.name) end update end #-------------------------------------------------------------------------- # * Disposição #-------------------------------------------------------------------------- def dispose bitmap.dispose if bitmap super end #-------------------------------------------------------------------------- # * Atualização do bitmap de origem #-------------------------------------------------------------------------- def update_bitmap unless $game_temp.animate_show_picture.nil? or $game_temp.animate_show_picture[0] != @picture.number if @count < 0 @index = @index >= @max ? 0 : @index.next name = @picture.name.split("_")[0].to_s + "_" + @index.to_s self.bitmap = Cache.picture(name) @count = @wait else @count -= 1 end else self.bitmap = Cache.picture(@picture.name) end endend