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 * Экран информации о уничтожении
15 public class Crash
extends Screen
{
17 private final Sprite window
;
18 private final Sprite leftSoft
;
19 private final Sprite rightSoft
;
20 private final Image downPanel
;
22 public Crash() throws IOException
{
23 Loader loader
= Loader
.getInstance();
26 Image windowImage
= loader
.getImage("/gfx/crash/window.png");
27 int windowX
= (screenW
- windowImage
.getWidth()) / 2;
28 int windowY
= (screenH
- windowImage
.getHeight()) / 2;
29 window
= new Sprite(windowImage
, windowX
, windowY
);
30 // здесь для окошка не обрабатываются события
33 Image rightSoftImage
= loader
.getImage("/gfx/awt/right_soft.png");
34 int rightSoftX
= screenW
- rightSoftImage
.getWidth();
35 int rightSoftY
= screenH
- rightSoftImage
.getHeight();
36 rightSoft
= new Sprite(rightSoftImage
, rightSoftX
, rightSoftY
);
37 rightSoft
.addEvent(new EventListener() {
40 return rightSoft
.isEntrySet(getXPressed(), getYPressed());
45 keyPressed(LEFT_SOFT
);
50 Image leftSoftImage
= loader
.getImage("/gfx/awt/left_soft.png");
52 int leftSoftY
= screenH
- leftSoftImage
.getHeight();
53 leftSoft
= new Sprite(leftSoftImage
, leftSoftX
, leftSoftY
);
54 leftSoft
.addEvent(new EventListener() {
57 return leftSoft
.isEntrySet(getXPressed(), getYPressed());
62 keyPressed(LEFT_SOFT
);
67 downPanel
= loader
.getImage("/gfx/awt/down_panel.png");
72 setDate(39, screenH
- 9);
78 while (getGameLoop()) {
82 LongFlight
.link
.sleep(20);
88 public void keyPressed(int keyCode
) {
89 switch (getGameAction(keyCode
)) {
97 LongFlight
.link
.setScreen(LongFlight
.MENU
);
103 public void pointerPressed(int x
, int y
) {
104 super.pointerPressed(x
, y
);
105 window
.exciteEvent();
106 rightSoft
.exciteEvent();
107 leftSoft
.exciteEvent();
110 private void update() {
112 Game
.link
.updateElements();
115 private void paint() {
116 space
.paint(graphics
);
117 Game
.link
.paintElements(graphics
);
118 window
.paint(graphics
);
119 for (int i
= 0; i
< screenW
; i
+= downPanel
.getWidth()) {
120 graphics
.drawImage(downPanel
, i
, screenH
- downPanel
.getHeight(), 0);
122 leftSoft
.paint(graphics
);
123 rightSoft
.paint(graphics
);