Advertisement
QuasiXi

Pop Up

Aug 25th, 2014
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.35 KB | None | 0 0
  1. #==============================================================================
  2. #** Quasi Pop Up [[ Snipet ]]
  3. #==============================================================================
  4. # Simple plug and play.
  5. # Makes pop up text with any text, location and duration.
  6. #
  7. # To use:
  8. # In the event, do the follow Script call:
  9. #  pop_up(string, duration, x, y, color)
  10. #   - string is the text you want to to pop up
  11. #   - duration is how long it should last ( default is 60 )
  12. #   - x, y are the location of where the text should pop at.
  13. #     x and y are set in the center of the screen by default.
  14. #   - color changes the color of the text, white by default.
  15. #
  16. # Example of popping a text on Event 2:
  17. #  Script Call:
  18. #   string = "test"
  19. #   x = $game_map.events[2].screen_x
  20. #   y = $game_map.events[2].screen_y
  21. #   color = Color.new(255,0,0,255)
  22. #   pop_up(string,60,x,y,color)
  23. #
  24. #==============================================================================#
  25. # By Quasi (http://quasixi.wordpress.com/)
  26. #  - 8/25/14
  27. #==============================================================================#
  28. #==============================================================================
  29. # ** Scene_Map
  30. #------------------------------------------------------------------------------
  31. #  This class performs the map screen processing.
  32. #==============================================================================
  33.  
  34. class Scene_Map < Scene_Base
  35.   alias qpop_update update
  36.   #--------------------------------------------------------------------------
  37.   # * Frame Update
  38.   #--------------------------------------------------------------------------
  39.   def update
  40.     qpop_update
  41.     update_pop if @pop_dur
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # * Update Pop up
  45.   #--------------------------------------------------------------------------
  46.   def update_pop
  47.     return unless @pop
  48.     zv = 1.0/(@pop_dur/4)
  49.     @pop.zoom_y += zv if @pop.zoom_y < 1
  50.    
  51.     @pop_dur -= 1
  52.     @pop.dispose if @pop_dur <= 0
  53.     @pop_dur = nil if @pop_dur <= 0
  54.   end
  55.   #--------------------------------------------------------------------------
  56.   # * Initiate Pop up
  57.   #--------------------------------------------------------------------------
  58.   def pop_up(string, duration, x, y, color)
  59.     color = Color.new(255,255,255,255) if color.nil?
  60.     @pop = Sprite.new
  61.     @pop.x = x - 100
  62.     @pop.y = y - 15
  63.     @pop.bitmap = Bitmap.new(200,30)
  64.     # rmvxa default fonts, but you can change to what you want
  65.     @pop.bitmap.font.name = ["Verdana", "Arial", "Courier New"]
  66.     @pop.bitmap.font.color = color
  67.     @pop.bitmap.draw_text(@pop.bitmap.rect, string, 1)
  68.     @pop_dur = duration
  69.     @pop.zoom_y = 0
  70.   end
  71. end
  72. #==============================================================================
  73. # ** Game_Interpreter
  74. #------------------------------------------------------------------------------
  75. #  An interpreter for executing event commands. This class is used within the
  76. # Game_Map, Game_Troop, and Game_Event classes.
  77. #==============================================================================
  78.  
  79. class Game_Interpreter
  80.   def pop_up(string, duration=60, x=Graphics.width/2, y=Graphics.height/2, color=nil)
  81.     return unless SceneManager.scene_is?(Scene_Map)
  82.     SceneManager.scene.pop_up(string, duration, x, y,color)
  83.   end
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement