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

📄 gamesplash.java

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

public class Gamesplash extends FullCanvas 
{
    Image image[];
    private Image image_bg;
    private Game_control game_control;
    private int colors[];
    private Timer timer;
    private int flashDuration;
    int swapped;
    boolean timers;
    int now_times;
    private int sel;
    int i =0;
    
    class Task8 extends TimerTask
    {

        public final void run()
        {
            if(timers)
            {
                now_times = now_times + 1;
                swapped = swapped + 1;
                if(swapped > image.length -1)
                    swapped = 0;
                repaint();
            }
        }

        Task8()
        {
        }
    }


    public Gamesplash(Game_control gc)
    {
        image = new Image[2];
        image_bg = null;
        colors = new int[8];
        timer = new Timer();
        flashDuration = 200;
        swapped = 0;
        timers = true;
        now_times = 0;
        sel = 1;
        game_control = gc;
        try
        {
            image[0] = Image.createImage("/splash1.png");
            image[1] = Image.createImage("/splash2.png");
           
        }
        catch(Exception ex) { }
        timer.scheduleAtFixedRate(new Task8(), 0L, flashDuration);
    }

    public void paint(Graphics g)
    {
        if(image[swapped] != null)
            switch(swapped)
            {
            case 0: // '\0'
                g.drawImage(image[swapped], 0, 0, 20);
                break;

            case 1: // '\001'
                g.drawImage(image[swapped], 70, 107, 20);
                break;
            }
 
            if(i<100)//????????????????进度条???????????????????????????????????????????????
            {
                /*Thread th = new Thread(this);
                try
                {
                    th.sleep(200);
                }
                catch(Exception e)
                {}
                */
                g.setColor(255,0,255);
                g.fillRoundRect(55,220,i++,20,20,20);//i为长度变化
             }   
            g.fillRoundRect(55,220,i,20,20,20);//i为长度变化
             
            
        if(now_times > 100)
        {
            killed();
            image = null;
            game_control.gamemenu();
        }
    }

    protected void keyPressed(int keyCode)
    {
        if(game_control != null)  //显示欢迎界面后,判断是否按下按键,如果按下则转到菜单界面
        {
            killed();
            image = null;
            game_control.gamemenu();
        }
    }

    public void killed()//取消任务计时
    {
        timer.cancel();
        timer = null;
    }

    public void g_cls(Graphics g, int setcolor)//设置最低图层的大小以及背景颜色
    {
        g.setColor(setcolor);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.drawImage(image_bg, 0, 0, 20);
    }

}

⌨️ 快捷键说明

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