- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorial.java
More file actions
Latest commit
84 lines (73 loc) · 3.11 KB
/
Copy pathTutorial.java
File metadata and controls
84 lines (73 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
importjavax.swing.*;
importjava.awt.*;
importjava.awt.event.*;
publicclassTutorialextendsJPanel {
privateString[] falas = {
"Ola, bem vindo ao mundo Pokemon!",
"Neste jogo você enfrentar desafios",
"e batalhas para se tornar um mestre Pokemon.",
"Agora me conte mais sobre voce."
};
privateintfalaIndex = 0;
privateJPanelnextPage;
publicTutorial(Gameframe ,String[] falas, JPanelnextPage) {
this.falas = falas;
this.nextPage = nextPage;
editar(frame);
}
privatevoideditar(Gameframe) {
setLayout(newBorderLayout());
FontFonte = DefinirFonte.fonte();
JLabelbackground = newJLabel();
background.setFocusable(true);
background.setIcon(newImageIcon("assets/backgroundImages/focusPage.png"));
background.setBounds(0, 0, 960, 640);
JLabelPersonagem= newJLabel();
Personagem.setFocusable(true);
Personagem.setIcon(newImageIcon("assets/personagens/professor.png"));
Personagem.setBounds( 350 , -50 , 960, 640);
JLabelTextArea= newJLabel();
TextArea.setFocusable(true);
TextArea.setIcon(newImageIcon("assets/backgroundImages/textarea.png"));
TextArea.setBounds( 25,200, 960, 640);
JButtoncaixaFalaBtn = newJButton(falas[falaIndex]);
caixaFalaBtn.setFont(Fonte.deriveFont(Font.PLAIN,50f));
caixaFalaBtn.setContentAreaFilled(false); // Tirar qualquer coisa que faça os botões ficarem coloridos
caixaFalaBtn.setBorderPainted(false); // Tirar as bordas
JButtonDialogoBox = caixaFalaBtn;
background.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("SPACE"), "spacePressed");
background.getActionMap().put("spacePressed", newAbstractAction() {
@Override
publicvoidactionPerformed(ActionEvente) {
if (falaIndex < falas.length - 1) {
System.out.println("Proxima fala");
falaIndex++;
DialogoBox.setText(falas[falaIndex]);
revalidate();
repaint();
} else {
System.out.println("proxima cena");
frame.mudarTela(nextPage);
}
}
});
DialogoBox.addActionListener(e -> {
System.out.println("Clicou no botao");
if (falaIndex < falas.length - 1) {
System.out.println("Proxima fala");
falaIndex++;
DialogoBox.setText(falas[falaIndex]);
revalidate();
repaint();
} else {
System.out.println("proxima cena");
frame.mudarTela(nextPage);
}
});
DialogoBox.setBounds( 60,450, 850, 140);
background.add(DialogoBox);
background.add(TextArea);
background.add(Personagem);
add(background, BorderLayout.NORTH);
}
}