Advertisement
Guill

Class Text < Sprite

Jun 25th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #=========================================================
  2. # Classe Text
  3. #---------------------------------------------------------
  4. # Mostra um texto definido em tempo de execução
  5. #---------------------------------------------------------
  6. # * Adicione um comando de evento Chamar Script com os
  7. # parâmetros a seguir:
  8. #
  9. # text = <seu texto aqui>
  10. # $systxt = Text.new(x,y,w,h,text)
  11. #
  12. # * Substitua X,Y,W e H por suas respectivas cordenadas de
  13. # tela.
  14. #
  15. #=========================================================
  16. class Text < Sprite
  17.    
  18.     #====================================
  19.     # Initialize
  20.     #------------------------------------
  21.     # * Inicializa a sprite
  22.     # * Cria uma bitmap
  23.     # * Seta o texto e a posição na bitmap
  24.     #====================================
  25.     def initialize(x,y,w,h,text)
  26.         super(nil)
  27.         @text = text
  28.         self.bitmap = Bitmap.new(w,h)
  29.         self.bitmap.draw_text(0,0,w,h,text)
  30.         self.x = x
  31.         self.y = y 
  32.     end
  33.    
  34.     #====================================
  35.     # Update
  36.     #------------------------------------
  37.     # * Atualiza a Sprite
  38.     #====================================
  39.     def update
  40.         super  
  41.     end
  42.    
  43.     #====================================
  44.     # Dispose
  45.     #------------------------------------
  46.     # * Dispõe a sprite
  47.     #====================================
  48.     def dispose
  49.         super
  50.     end
  51.    
  52.     #====================================
  53.     # Change Text
  54.     #------------------------------------
  55.     # * Muda o texto da bitmap
  56.     # * Muda a posição da bitmap
  57.     #====================================
  58.     def change_text(x,y,w,h,text)
  59.         self.bitmap.clear
  60.         self.bitmap = Bitmap.new(w,h)
  61.         self.bitmap.draw_text(0,0,w,h,text)
  62.         self.x = x
  63.         self.y = y     
  64.     end
  65.    
  66. end
  67. #=========================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement