📄 happyevent.java
字号:
/*
* HappyEvent.java
*
* Created on 2006年5月5日, 上午11:25
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package DogPet;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.*;
// Referenced classes of package com.webineti:
// GameData, GameView
public class HappyEvent
{
class Task9 extends TimerTask
{
public final void run()
{
if(GameView.events == -1)
{
swapped = swapped + 1;
if(swapped > happy.length - 1)
swapped = 0;
view.repaint();
}
}
Task9()
{
}
}
public void add_data()
{
GameData.Intelligence += 5;
if(GameData.Intelligence > 100)
GameData.Intelligence = 100;
GameData.Capacity--;
if(GameData.Capacity < 0)
GameData.Capacity = 0;
}
public HappyEvent(GameView view)
{
swapped = 0;
repeat = 0;
start_x = 0;
start_y = 0;
image_bg = null;
timer = new Timer();
flashDuration = 1000;
happy = new Image[3];
this.view = view;
try
{
happy[0] = Image.createImage("/happy/dog_happy1.png");
happy[1] = Image.createImage("/happy/dog_happy2.png");
//happy[2] = Image.createImage("/happy/dog_happy3.png");
}
catch(Exception ex) { }
timer.scheduleAtFixedRate(new Task9(), 0L, flashDuration);
}
public void paint(Graphics g)
{
this.g = g;
if(happy[swapped] != null)
{
view.g_cls(g, 0);
g.drawImage(happy[0], GameData.start_x, start_y + 72, 20);
switch(swapped)
{
case 0: // '\0'
g.drawImage(happy[1], GameData.start_x + 51, start_y + 72 + 25, 20);
break;
case 1: // '\001'
g.drawImage(happy[swapped], GameData.start_x + 51, start_y + 72 + 25, 20);
break;
case 2: // '\002'
g.drawImage(happy[swapped], GameData.start_x + 51, start_y + 72 + 25, 20);
break;
}
}
}
public void killed()
{
timer.cancel();
timer = null;
}
GameView view;
private Graphics g;
int swapped;
private int repeat;
private int start_x;
private int start_y;
private Image image_bg;
private Timer timer;
private int flashDuration;
Image happy[];
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -