Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module GI_Colors
- COLORS = {
- #------------------------------
- # Insira novas cores aqui
- #------------------------------
- # "nome da cor" => Color.new(Valor RGB),
- #
- # Não esqueça da virgula.
- #------------------------------
- "clWhite" => Color.new(255,255,255),
- "clBlack" => Color.new(0,0,0)
- #...
- #------------------------------
- }
- end
- #=========================================================
- # Classe Text
- #---------------------------------------------------------
- # Mostra um texto definido em tempo de execução
- #---------------------------------------------------------
- # * Adicione um comando de evento Chamar Script com os
- # parâmetros a seguir:
- #
- # text = <seu texto aqui>
- # $systxt = Text.new(x,y,w,h,text)
- #
- # * Substitua X,Y,W e H por suas respectivas cordenadas de
- # tela.
- #
- #=========================================================
- class Text < Sprite
- attr_accessor :font_color
- attr_accessor :font_name
- attr_accessor :text
- #====================================
- # Initialize
- #------------------------------------
- # * Inicializa a sprite
- # * Cria uma bitmap
- # * Seta o texto e a posição na bitmap
- #====================================
- def initialize(x,y,w,h,text)
- super(nil)
- @text = text
- self.bitmap = Bitmap.new(w,h)
- self.bitmap.draw_text(0,0,w,h,text)
- self.x = x
- self.y = y
- @font_name = self.bitmap.font.name
- @font_color = 'clWhite'
- end
- #====================================
- # Update
- #------------------------------------
- # * Atualiza a Sprite
- #====================================
- def update
- self.text = @text
- self.font_color = @font_color
- self.font_name = @font_name
- super
- end
- #====================================
- # Dispose
- #------------------------------------
- # * Dispõe a sprite
- #====================================
- def dispose
- super
- end
- #====================================
- # Change Text
- #------------------------------------
- # * Muda o texto da bitmap
- # * Muda a posição da bitmap
- #====================================
- def change_text(x,y,w,h,text)
- self.bitmap.clear
- self.bitmap = Bitmap.new(w,h)
- @text = text
- self.bitmap.draw_text(0,0,w,h,text)
- self.x = x
- self.y = y
- end
- #====================================
- # Change Font
- #------------------------------------
- # * Muda a fonte do texto da bitmap
- #====================================
- def change_font(name,color)
- self.bitmap.font.name = name
- self.bitmap.font.color = GI_Colors::COLORS[color]
- @font_name = name
- @font_color = GI_Colors::COLORS.index(self.bitmap.font.color)
- end
- end
- #=========================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement