opening window animation?
(sorry if this is the wrong board, wasn't sure if this should go here or learning rgss. or something.)howdy! i'm trying to setup a simple popup window- currently for tutorials, but the script will probably have other applications elsewhere- and i'm struggling to get the nice little window opening animation that's used for the messages and most other built-in game windows to appear on mine.
i currently have this (ft. placeholder text for testing):
Ruby:
#------------------------------------------------------------------------------ # WINDOWPOP #------------------------------------------------------------------------------ # manages popup boxes in the upper left corner # # called with # AO_Windowpop.new(#,:{text source}) # with the # being the style id for the type of window, # and the :{text_source} being the symbol key for the text. #------------------------------------------------------------------------------ class AO_Windowpop #------------------------------------------------------------------------------ def initialize(style,ref) reset_all source(ref) draw_dummy_window get_window_dimensions(style) end # init def reset_all # resets all class and global variables $winpop_dummy_width = 0 @src = nil @ref = nil end # reset_all def source(ref) # defines text source loc = AO::SAMPLETEXT @src = loc @ref = ref end # source def draw_dummy_window # makes an invisible window to determine how wide the real one has to be width = Windowpop_dummy.new width.get(@ref) end def get_window_dimensions(style) #defines the style of the window (may break into multiple blocks l8r) tally = 0 case style when 1 # unlock window; 1 line, appears for 2 sec & vanishes x = $winpop_dummy_width + 36 y = 48 input = false center = true when 2 # tutorial window; multiple lines, stays open until a button is pressed @src.each {|k,v| x = $winpop_dummy_width + 24 tally += 1 y = (24*tally)+(tally*8) input = true center = false} end # case call_window(x,y,input,center) end # get_window_dimensions def call_window(x,y,input,center) # makes window window = AO_Windowpop_Window.new(100,60,x,y) window.direct(input,center,@ref) end # call_window #------------------------------------------------------------------------------ end #Windowpop #------------------------------------------------------------------------------ class AO_Windowpop_Window < Window_Base #------------------------------------------------------------------------------ def initialize(x,y,width,height) super(x,y,width,height) self.back_opacity = 255 reset_all end # init def reset_all #resets all class variables @src = nil end # reset_all def direct(input,center,ref) # calls building processes w/ their requisite arguments update_open source_text(ref) tp_draw_text(center) input == true ? input_pause : hold_two_seconds update_close dispose end # direct def source_text(ref) # sets the text source loc = AO::SAMPLETEXT @src = loc end # source_text def tp_draw_text(center) # draws the text @src.each {|k,v| txt = v center == true ? x = contents_width/2-text_size(txt).width/2 : x = 0 y = line_height*k draw_text_ex(x,y,txt)} end # tp_draw_text def input_pause # pauses until a button is pressed self.pause = true wait(10) Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) Input.update self.pause = false end # input_update def wait(duration) # defines what a pause is duration.times { Fiber.yield } end # wait def hold_two_seconds # pauses for 2 seconds wait(120) end#------------------------------------------------------------------------------ end #Windowpop_window #------------------------------------------------------------------------------ class Windowpop_dummy < Window_Base #------------------------------------------------------------------------------ def initialize super(0,0,0,0) hide end # init def get(ref) # compares the size of each line & sets the variable to the largest one src = AO::SAMPLETEXT max = 0 src.each{|k,v| current = text_size(v).width max = current if current > max} $winpop_dummy_width = max end # get #------------------------------------------------------------------------------ end # Windowpop_dummy #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ module AO #------------------------------------------------------------------------------ SAMPLETEXT = { :unlock => {0 => "Unlocked Something!"}, :tutorial => {0=> "SOMETHING:",1 => "- How to do it",2 => "- When to do it"}, } # sampletext #------------------------------------------------------------------------------ end # AO #------------------------------------------------------------------------------
(definitely not as neat as it could be, but it works fine for what i'm using it for)
and the windows just kind of pop in and out of existence. i was under the impression update_open and update_close were what performed that, which is why i specifically called them while building the window, but either i completely misunderstood, or i just did it wrong.
any assistance would be greatly appreciated!
本贴来自国际rpgmaker官方论坛作者:voidsumbrella处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/opening-window-animation.181218/
页:
[1]