?? eatevent.java
字號(hào):
/*
* EatEvent.java
*
* Created on 2006年5月5日, 上午10:58
*
* 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 EatEvent
{
class Task4 extends TimerTask
{
public final void run()
{
if(GameView.events == 0)
{
swapped = swapped + 1;
if(swapped > eat.length - 1)
{
swapped = 0;
GameView.events = -1;
}
view.repaint();
}
}
Task4()
{
}
}
public void add_data()
{
GameData.Mood += 5;
if(GameData.Mood > 100)
GameData.Mood = 100;
GameData.Capacity += 5;
if(GameData.Capacity > 100)
GameData.Capacity = 100;
GameData.Weight += 5;
if(GameData.Weight > 100)
GameData.Weight = 100;
}
public EatEvent(GameView view)
{
swapped = 0;
image_bg = null;
start_x = 0;
start_y = 0;
timer = new Timer();
flashDuration = 1000;
eat = new Image[3];
this.view = view;
try
{
eat[0] = Image.createImage("/eat/dog_eat1.png");
eat[1] = Image.createImage("/eat/dog_eat3.png");
eat[2] = Image.createImage("/eat/dog_eat5.png");
}
catch(Exception ex) { }
timer.scheduleAtFixedRate(new Task4(), 0L, flashDuration);
}
public void paint(Graphics g)
{
this.g = g;
if(eat[swapped] != null)
{
view.g_cls(g, 0);
g.drawImage(eat[swapped], GameData.start_x + 20, GameData.start_y + 85, 20);
}
}
public void killed()
{
timer.cancel();
timer = null;
}
GameView view;
private Graphics g;
int swapped;
private Image image_bg;
private int start_x;
private int start_y;
private Timer timer;
private int flashDuration;
Image eat[];
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -