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

📄 loadbar.java

📁 《神州》RPG游戏引擎
💻 JAVA
字号:
import java.util.Timer;
import java.util.TimerTask;

import javax.microedition.lcdui.*;

public class LoadBar extends GameCanvas implements Runnable
{
    private Graphics g;
    boolean isPlay;
    int percent;
    
    Display disp;
    Displayable last;
    public LoadBar(Display disp,Displayable last) {
        super(false);
        this.disp=disp;
        this.last=last;
        this.g=this.getGraphics();
        
    }
    public void start()
    {
        isPlay=true;
        (new Thread(this)).start();
    }
    public void stop()
    {
        isPlay=false;
    }
    
    public void run()
    {
        while(isPlay)
        {
            g.setColor(0x000000);
            g.fillRect(0,0,this.getWidth(),this.getHeight());
            int barL=(this.getWidth()-20)*percent/100;
            g.setColor(0x0000FF);
            g.fillRect(10,this.getHeight()/2-5,barL,10);
            g.setColor(0xFFFFFF);
            g.drawRect(10,this.getHeight()/2-5,this.getWidth()-20,10);
            g.drawString(percent+"%",this.getWidth()/2,this.getHeight()/2-5-Style.font.getHeight()-3,Style.CT);
            this.flushGraphics();
            
            if(percent>=100)
            {                
                stop();
                Timer timer=new Timer();
                TimerTask timerTask=new TimerTask()
                {
                    public void run()
                    {
                        disp.setCurrent(last);
                    }
                };
                timer.schedule(timerTask,200);                
                  
            }
           
            try {
                Thread.sleep(1000/60);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            
        }
        //GameMIDlet.midlet.clearObj(this);
    }

}

⌨️ 快捷键说明

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