⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 washevent.java

📁 关于j2me的宠物游戏!!!!!!!!!!! 希望打架提出意见
💻 JAVA
字号:
/*
 * WashEvent.java
 *
 * Created on 2006年5月5日, 上午11:55
 *
 * 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 WashEvent
{
    class Task extends TimerTask
    {

        public final void run()
        {
            if(GameView.events == 7)
            {
                swapped = swapped + 1;
                if(swapped > watsh.length - 1)
                {
                    swapped = 0;
                    repeat++;
                    if(repeat > 3)
                    {
                        repeat = 0;
                        GameView.events = -1;
                    }
                }
                view.repaint();
            }
        }

        Task()
        {
        }
    }


    public void add_data()
    {
        GameData.Mood += 5;
        if(GameData.Mood > 100)
            GameData.Mood = 100;
        GameData.Health += 5;
        if(GameData.Health > 100)
            GameData.Health = 100;
    }

    public WashEvent(GameView view)
    {
        repeat = 0;
        swapped = 0;
        start_x = 0;
        start_y = 0;
        image_bg = null;
        timer = new Timer();
        flashDuration = 500;
        watsh = new Image[2];
        this.view = view;
        try
        {
            watsh[0] = Image.createImage("/watshing/dog_watshing1.png");
            watsh[1] = Image.createImage("/watshing/dog_watshing2.png");
        }
        catch(Exception ex) { }
        timer.scheduleAtFixedRate(new Task(), 0L, flashDuration);
    }

    public void paint(Graphics g)
    {
        this.g = g;
        if(watsh[swapped] != null)
        {
            view.g_cls(g, 0);
            g.drawImage(watsh[0], GameData.start_x + 10, GameData.start_y + 72, 20);
            switch(swapped)
            {
            case 1: // '\001'
                g.drawImage(watsh[swapped], GameData.start_x + 10 + 20, GameData.start_y + 72 + 13, 20);
                break;
            }
        }
    }

    public void killed()
    {
        timer.cancel();
        timer = null;
    }

    GameView view;
    private Graphics g;
    int repeat;
    int swapped;
    private int start_x;
    private int start_y;
    private Image image_bg;
    private Timer timer;
    private int flashDuration;
    Image watsh[];
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -