1 package code
.kalter
.longflight
.screen
;
3 import code
.kalter
.longflight
.EventListener
;
4 import code
.kalter
.longflight
.Loader
;
5 import code
.kalter
.longflight
.LongFlight
;
6 import code
.kalter
.longflight
.Sprite
;
7 import java
.io
.IOException
;
8 import javax
.microedition
.lcdui
.Image
;
11 * Специальный экран, предназначенный для временной задержки действующего экрана
12 * и одновременным контактом с пользователем. Жёстко привязан к игровому экрану
16 public class Pause
extends Screen
{
18 private static final int COUNT
= 2; //choise
20 private static final int FIGHT
= 0;
21 private static final int MENU
= 1;
23 private final Sprite
[] choise
;
24 private final Sprite
[] selectChoise
;
25 private final Sprite window
;
26 private final Sprite leftSoft
;
27 private final Sprite rightSoft
;
28 private final Image downPanel
;
32 public Pause() throws IOException
{
34 Loader loader
= Loader
.getInstance();
37 Image windowImage
= loader
.getImage("/gfx/pause/window.png");
38 int windowX
= (screenW
- windowImage
.getWidth()) / 2;
39 int windowY
= (screenH
- windowImage
.getHeight()) / 2;
40 window
= new Sprite(windowImage
, windowX
, windowY
);
43 Image rightSoftImage
= loader
.getImage("/gfx/awt/right_soft.png");
44 int rightSoftX
= screenW
- rightSoftImage
.getWidth();
45 int rightSoftY
= screenH
- rightSoftImage
.getHeight();
46 rightSoft
= new Sprite(rightSoftImage
, rightSoftX
, rightSoftY
);
47 rightSoft
.addEvent(new EventListener() {
50 return rightSoft
.isEntrySet(getXPressed(), getYPressed());
60 Image leftSoftImage
= loader
.getImage("/gfx/awt/left_soft.png");
62 int leftSoftY
= screenH
- leftSoftImage
.getHeight();
63 leftSoft
= new Sprite(leftSoftImage
, leftSoftX
, leftSoftY
);
64 leftSoft
.addEvent(new EventListener() {
67 return leftSoft
.isEntrySet(getXPressed(), getYPressed());
77 downPanel
= loader
.getImage("/gfx/awt/down_panel.png");
80 Image choiseCrop
= loader
.getImage("/gfx/pause/choise.png");
81 choise
= new Sprite
[COUNT
];
82 selectChoise
= new Sprite
[COUNT
];
83 for (int i
= 0; i
< COUNT
; i
++) {
85 Image c
= Image
.createImage(choiseCrop
, 0, i
* 22, 102, 22, 0);
86 int choiseX
= (screenW
- 102) / 2;
87 int choiseY
= window
.getY() + 34 + i
* 24;
88 choise
[i
] = new Sprite(c
, choiseX
, choiseY
);
91 Image sc
= Image
.createImage(choiseCrop
, 102, i
* 22, 102, 22, 0);
92 int selectChoiseX
= choise
[i
].getX();
93 int selectChoiseY
= choise
[i
].getY();
94 selectChoise
[i
] = new Sprite(sc
, selectChoiseX
, selectChoiseY
);
97 // adding event listener for choise about of "fight"
98 choise
[FIGHT
].addEvent(new EventListener() {
100 public boolean is() {
101 return choise
[FIGHT
].isEntrySet(getXPressed(), getYPressed());
105 public void event() {
111 // adding event listener for choise about of "menu"
112 choise
[MENU
].addEvent(new EventListener() {
114 public boolean is() {
115 return choise
[MENU
].isEntrySet(getXPressed(), getYPressed());
119 public void event() {
128 while (getGameLoop()) {
132 LongFlight
.link
.sleep(20);
138 public void start() {
139 setDate(39, screenH
- 9);
144 public void keyPressed(int keyCode
) {
145 switch (getGameAction(keyCode
)) {
170 public void pointerPressed(int x
, int y
) {
171 super.pointerPressed(x
, y
);
172 leftSoft
.exciteEvent();
173 rightSoft
.exciteEvent();
174 choise
[FIGHT
].exciteEvent();
175 choise
[MENU
].exciteEvent();
178 private void upPressed() {
179 if (--position
< 0) {
184 private void downPressed() {
185 if (++position
>= COUNT
) {
186 position
= COUNT
- 1;
190 private void leftSoftPressed() {
194 private void rightSoftPressed() {
199 private void firePressed() {
202 LongFlight
.link
.setScreen(LongFlight
.GAME
);
206 Game
.link
.setNullPause();
207 LongFlight
.link
.setScreen(LongFlight
.MENU
);
212 private void update() {
216 private void paint() {
217 space
.paint(graphics
);
218 Game
.link
.paintElements(graphics
);
219 window
.paint(graphics
);
222 leftSoft
.paint(graphics
);
223 rightSoft
.paint(graphics
);
228 private void paintChoise() {
229 for (int i
= 0; i
< COUNT
; i
++) {
231 selectChoise
[i
].paint(graphics
);
233 choise
[i
].paint(graphics
);
238 private void paintDownPanel() {
239 for (int i
= 0; i
< screenW
; i
+= 128) {
240 graphics
.drawImage(downPanel
, i
, screenH
- 18, 0);