SHOW:
|
|
- or go back to the newest paste.
1 | - | #========================================================================= |
1 | + | #========================================================= |
2 | # Classe Text | |
3 | - | #------------------------------------------------------------------------- |
3 | + | #--------------------------------------------------------- |
4 | - | # Cole o código abaixo no chamar evento |
4 | + | # Mostra um texto definido em tempo de execução |
5 | #--------------------------------------------------------- | |
6 | - | # txt = "texto que você quer mostrar" |
6 | + | # * Adicione um comando de evento Chamar Script com os |
7 | - | # $txt = Text.new(x,y,w,h,txt) |
7 | + | # parâmetros a seguir: |
8 | # | |
9 | - | # Substitua x,y,w e h pelas cordenadas x e y da tela, a largura e a altura. Respectivamente. |
9 | + | # text = <seu texto aqui> |
10 | - | #========================================================================= |
10 | + | # $systxt = Text.new(x,y,w,h,text) |
11 | # | |
12 | - | def initialize(x,y,w,h,txt) |
12 | + | # * Substitua X,Y,W e H por suas respectivas cordenadas de |
13 | - | super(nil) |
13 | + | # tela. |
14 | - | self.bitmap = Bitmap.new(w,h) |
14 | + | |
15 | - | self.bitmap.draw_text(0,0,w,h,txt) |
15 | + | #========================================================= |
16 | - | @x = x |
16 | + | |
17 | - | @y = y |
17 | + | |
18 | - | end |
18 | + | #==================================== |
19 | - | def update |
19 | + | # Initialize |
20 | - | super |
20 | + | #------------------------------------ |
21 | - | self.x = @x |
21 | + | # * Inicializa a sprite |
22 | - | self.y = @y |
22 | + | # * Cria uma bitmap |
23 | - | end |
23 | + | # * Seta o texto e a posição na bitmap |
24 | - | def dispose |
24 | + | #==================================== |
25 | - | self.bitmap.clear |
25 | + | def initialize(x,y,w,h,text) |
26 | - | super |
26 | + | super(nil) |
27 | - | end |
27 | + | @text = text |
28 | - | end |
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 | #========================================================= |