Text Scroll Script é um script para RPG Maker XP que permite rolar textos durante a gameplay. Também se pode ter livros com múltiplas imagens e conta com várias condições e opções para personalizar.
Text Scroll Script é um script para rolagem de textos em projetos do RPG Maker XP criado pelo Dubealex.
O script permite rolar textos armazenados em um arquivo de texto na sua pasta de projeto durante a gameplay. Você também pode ter livros com múltiplas imagens e usar várias condições e opções para personalizar cores e velocidade.
Insira o código abaixo acima do Main. Alternativamente, você pode baixar a demo para entender melhor. Vem também com o código da versão R3 no pacote de download:
#=============================================================================== # ■ Text Scroll Script - R3.2 - Created by Dubealex # Last updated: October 28, 2007 # # ● Full SDK 2.3 Compatible (Does NOT need or require SDK 2.3) #=============================================================================== # For more infos and update, visit: # www.creationasylum.net # # ● IMPORTANT NOTE ABOUT BOOK SCROLL: # Always add a 5 Frames WAIT just before and just after your book scroll # call script, otherwise menu and message windows might have a problem. # # ● Enhancement for R3.1 done by: DerVVulfman (04-26-2007) # - Modified script so it can go even slower # - Added a font change option # - Added comments that explain different parts of the script # # ● Release 3.2 - October 28, 2007: # - Reformated code to reflect my other script # - Fixed a bug from the enhanced R3.1 version in live Scroll feature # - Modified how the font/size settings are created and saved # - The font settings are saved in the save file #=============================================================================== #=============================================================================== # ▼ CLASS TSS_Settings Begins # This class manage the Text Scroll font settings #=============================================================================== class TSS_Settings def initialize $tss_settings = Array.new #=========================================================================== # ■ TEXT SCROLL MAIN SETTINGS: # tss_settings[0] is the font name you want to use # tss_Settings[1] is the font size you want to use # To modify those during the game, use the following in a call script: # $tss_settings[0]="fontname" or $tss_settings[1]=fontsize # #=========================================================================== $tss_settings[0] = 'Cartoon' #fontname, exact name, in quotation marks $tss_settings[1] = 24 #fontsize, no quotation marks #--- ■ END OF SETTINGS------------------------------------------------------ end end #=============================================================================== # ▲ CLASS TSS_Settings Ends #=============================================================================== #=============================================================================== # ▼ CLASS Text_Scroller Begins # This class performs enhanced text display processing. #=============================================================================== class Text_Scroller def initialize (file, opacity_scroll, opacity_bg, speed, live_scroll) # Read the text file text=IO.readlines("Text/#{file}") # Set Speed global value to speed $tss_speed = speed # Divide the screen height by the speed value $tss_iteration = 480.0 / speed # Set the size of the displayed text (from the file) $tss_sy = (text.size * 32) + 64 # Set the scrolling text window, text... size & all $tss_scroll_window = Window_Scroll.new(file, 640, $tss_sy) $tss_scroll_window.opacity = opacity_scroll # Place the window at the bottom of the screen & etc $tss_scroll_window.z = 500 $tss_scroll_window.x = 0 $tss_scroll_window.y = 480 # Set 'Y-Positioner' to use decimal values $tss_scroll_y_pos = 480.0 # Set the background, opacities & such $tss_bg_window = Window_bg.new $tss_bg_window.opacity = opacity_bg $tss_bg_window.z=400 # Switch between 'live scroll' feature or regular case live_scroll when 0 # Perform normal update update when 1 # Set to Live Scroll, and use the Scene_Map's Update $live_scroll = true end end #------------------------------------------------------------------------------- def update # Scroll through the estimated window size & place properly. for i in 0...(($tss_sy / 480.0) * $tss_iteration) + $tss_iteration $tss_scroll_y_pos -= $tss_speed $tss_scroll_window.y = $tss_scroll_y_pos.to_i Graphics.update end # Dispose of window & window background $tss_scroll_window.dispose $tss_bg_window.dispose end end #=============================================================================== # ▲ CLASS Text_Scroller Ends #=============================================================================== #=============================================================================== # ▼ CLASS Window_Scroll Begins # This window is used to display text for the scrolling display system #=============================================================================== class Window_Scroll < Window_Base def initialize (file, sx, sy) @sx=sx @sy=sy super(0, 0, sx, sy) self.contents = Bitmap.new(width - 32, height - 32) # Reset the font. If not called, set to Tahoma. $tss_settings[0] = "Tahoma" if $tss_settings[0] == nil self.contents.font.name = $tss_settings[0] # Reset the font size. If not called, set to 24 $tss_settings[1] = 24 if $tss_settings[1] == nil self.contents.font.size = $tss_settings[1] @text=IO.readlines("Text/#{file}") @text_color=0 refresh end #------------------------------------------------------------------------------- def refresh y = 0 for i in 0...@text.size y += 32 if @text[i].index('/') == 0 @text_color=@text[i].slice! (0..2) @text_color.slice!(0) end if @text[i].index('*') == 0 line_color=@text[i].slice! (0..2) line_color.slice!(0) self.contents.font.color = text_color(line_color.to_i) else self.contents.font.color = text_color(@text_color.to_i) end self.contents.draw_text(0, y, @sx, 32, @text[i]) end end end #=============================================================================== # ▲ CLASS Window_Scroll Ends #=============================================================================== #=============================================================================== # ▼ CLASS Book_Scroll Begins # This class performs Book simulation systems. #=============================================================================== class Book_Scroll def initialize (book_name, number_of_pages, start_page, opacity_scroll, opacity_bg) # Obtain the book name & Read the text file file = book_name.to_s+"/"+start_page.to_s+".rxdata" text=IO.readlines("Text/#{file}") $tss_sy= (text.size*32) + 64 # Set the scrolling window $tss_scroll_window = Window_Scroll.new(file, 640, $tss_sy) $tss_scroll_window.opacity = opacity_scroll $tss_scroll_window.z=500 $tss_scroll_window.x = 0 $tss_scroll_window.y = 0 $tss_scroll_y_pos = 0.0 # Set the background window $tss_bg_window = Window_bg.new $tss_bg_window.opacity = opacity_bg $tss_bg_window.z=400 # Update the displayed page book_update(book_name, start_page, number_of_pages, opacity_scroll, opacity_bg) # $game_system.menu_disabled = true (Not needed...) end #------------------------------------------------------------------------------- def book_update(book_name,start_page, number_of_pages, opacity_scroll, opacity_bg) # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # If the right directional button was pressed & not at the book's start. # IE: Turning a page if Input.repeat?(Input::RIGHT) and number_of_pages > 1 unless start_page == number_of_pages start_page+=1 else start_page=1 end # Dispose of windows $tss_scroll_window.dispose $tss_bg_window.dispose # Obtain new page from book file Book_Scroll.new(book_name, number_of_pages,start_page, opacity_scroll, opacity_bg) break end # If the left directional button was pressed & not at the book's start # IE: Turning a page if Input.repeat?(Input::LEFT) and number_of_pages > 1 unless start_page == 1 start_page-=1 else start_page=number_of_pages end # Dispose of windows $tss_scroll_window.dispose $tss_bg_window.dispose # Obtain new page from book file Book_Scroll.new(book_name, number_of_pages,start_page, opacity_scroll, opacity_bg) break end # If up directional button is pushed if Input.repeat?(Input::UP) $tss_scroll_window.y+=15 end # If down directional button is pushed if Input.repeat?(Input::DOWN) $tss_scroll_window.y-=15 end # If ESC button was pressed if Input.trigger?(Input::B) # Dispose of Windows $tss_scroll_window.dispose $tss_bg_window.dispose # Re-enable menu # $game_system.menu_disabled = false (Not needed...) break end end end end #=============================================================================== # ▲ CLASS Book_Scroll Ends #=============================================================================== #=============================================================================== # ▼ CLASS Scene_Map Additional Code Begins # This class performs map screen processing. #=============================================================================== class Scene_Map alias alex_tss_original_update update def update # Set counter to 0 (replaces the for... in Text_Scroller) @@i=0 # Perform the original call alex_tss_original_update # Perform if Live Update flag is true if $live_scroll $tss_scroll_y_pos -= $tss_speed $tss_scroll_window.y = $tss_scroll_y_pos.to_i @@i += 1 if @@i ==(($tss_sy/480.0) * $tss_iteration) + $tss_iteration $tss_scroll_window.dispose $tss_bg_window.dispose @@i=0 # Turn Live Update switch to false (turn system off) $live_scroll = false end end end end #=============================================================================== # ▲ CLASS Scene_Map Additional Code Ends #=============================================================================== #=============================================================================== # ▼ CLASS Window_bg Begins # This window displays a background window for the text scrolling systems. #=============================================================================== class Window_bg < Window_Base def initialize super(0, 0, 640, 480) end end #=============================================================================== # ▲ CLASS Window_bg Ends #=============================================================================== #=============================================================================== # ▼ CLASS Scene_Save Additional Code Begins # Here we save text scroll font and size when the game is saved #=============================================================================== class Scene_Save < Scene_File alias tss_original_write_save_data write_save_data def write_save_data(file) tss_original_write_save_data(file) Marshal.dump($tss_settings, file) end end #=============================================================================== # ▲ CLASS Scene_Save Additional Code Ends #=============================================================================== #=============================================================================== # ▼ CLASS Scene_Load Additional Code Begins # Here we load text scroll font and size when the game is loaded #=============================================================================== class Scene_Load < Scene_File alias tss_original_read_save_data read_save_data def read_save_data(file) tss_original_read_save_data(file) $tss_settings = Marshal.load(file) end end #=============================================================================== # ▲ CLASS Scene_Load Additional Code Ends #=============================================================================== #=============================================================================== # ▼ CLASS Scene_Title Additional Code Begins # Here we initialize everything needed to work with parrallax at game start #=============================================================================== class Scene_Title TSS_Settings.new end #=============================================================================== # ▲ CLASS Scene_Title Additional Code Ends #===============================================================================
Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Acesse aqui e saiba como. Obrigado!