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

📄 developercanvas.java

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

import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
import javax.microedition.midlet.*;

//import com.nokia.mid.ui.FullCanvas;

public class DeveloperCanvas extends GameCanvas implements Runnable
{
    private Display disp;
    private Displayable last;

    Graphics g;
    boolean isPlay;
    int delay;
    int width;
    int height;
    boolean isDrawing;
    int posY; //显示Y坐标
    int HSpace;


    int windowX,windowY; //可见视窗左上角坐标

    int runStatus;
    
    Image trans;
    
    Image transTop;
    int[] transArr;

    
    static final int LEFT_PRESSED=0x0004;
    static final int RIGHT_PRESSED=0x0020;
    static final int UP_PRESSED=0x0002;
    static final int DOWN_PRESSED=0x0040;
    

 

    public DeveloperCanvas(String title,Display disp,Displayable last)
    {
        super(false);
        this.disp = disp;
        this.last = last;
        this.setFullScreenMode(true);

        init();
    }
    public void init()
    {        
        this.g = getGraphics();
        delay = 1000/30;
        width = this.getWidth();
        height = this.getHeight();    
        
        posY = height;
        
        HSpace = 24;
        
        
        if(width>=176)
        {
            if(height<208)
            {
                height=208;
            }
        }
        
        
        /*
        transArr = new int[width*40];
        int index=0;
        for(int y=0;y<40;y++)
        {
        	for(int x=0;x<width;x++)
        	{
        		//transArr[index]=(y*(255/35)>255?255:y*(255/35))<<24 | 0x000000;
        		transArr[index]=0xFFFF0000;
        		index++;
        	}        	
        }
        trans = Image.createRGBImage(transArr,width,40,true);
        */
        
        trans = Tools.getImage("/pic/trans.png");        
      
        /*
        index=0;
        for(int y=0;y<40;y++)
        {
        	for(int x=0;x<width;x++)
        	{
        		//transArr[index]=((40-y)*(255/35)>255?255:(40-y)*(255/35))<<24 | 0x000000;
        		transArr[index]=0xDDFF0000;		
        		index++;
        	}        	
        }
        //transTop = Image.createRGBImage(transArr,width,40,true);
        */
        transTop = Image.createImage(trans,0,0,176,40,Sprite.TRANS_MIRROR_ROT180);
       
        
        GameMIDlet.midlet.setMusic(0);
        GameMIDlet.midlet.playSound();
    }

    boolean ThreadRunning;

    public void start()
    {
        isPlay = true;
        if(!ThreadRunning)
        {
            (new Thread(this)).start();
            ThreadRunning=true;
        }

    }
    public void stop()
    {
        isPlay=false;
    }


    public void run()
    {
        while(isPlay)
        {
            redrawAll();            
            
            try {
                Thread.sleep(delay);
                //wait(delay);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            
        }
        ThreadRunning = false;
    }
    
    public void redrawAll()
    {
        if(!isDrawing)
        {
            isDrawing = true;
            
            g.setColor(0);
            g.fillRect(0,0,width,height);
            
            
            g.setColor(255,255,0);
            g.drawString("设计总监",width/2,posY,Style.CT);
            g.setColor(255,255,255);
            g.drawString("黄琰",width/2,posY+ HSpace,Style.CT);
            g.setColor(255,255,0);
            g.drawString("对话设计",width/2,posY + HSpace*2,Style.CT);
            g.setColor(255,255,255);
            g.drawString("黄琰",width/2,posY + HSpace*3,Style.CT);
            g.setColor(255,255,0);
            g.drawString("地图设计",width/2,posY+ HSpace*4,Style.CT);
            g.setColor(255,255,255);
            g.drawString("黄琰",width/2,posY+ HSpace*5,Style.CT);
            g.setColor(255,255,0);
            g.drawString("主程序",width/2,posY+ HSpace*6,Style.CT);
            g.setColor(255,255,255);
            g.drawString("黄琰",width/2,posY+ HSpace*7,Style.CT);
            g.setColor(255,255,0);
            g.drawString("音乐",width/2,posY+ HSpace*8,Style.CT);
            g.setColor(255,255,255);
            g.drawString("黄琰",width/2,posY+ HSpace*9,Style.CT);
            g.setColor(255,255,0);
            g.drawString("游戏测试",width/2,posY+ HSpace*10,Style.CT);
            g.setColor(255,255,255);
            g.drawString("胥晓静  黄琰",width/2,posY+ HSpace*11,Style.CT);
            g.setColor(255,136,73);
            g.drawString("黄琰测试作品 2007.1.31",width/2,posY+ HSpace*16,Style.CT);
            g.drawString("E-mail:alexhy@163.com",width/2,posY+ HSpace*17,Style.CT);
            g.drawString("QQ:564586494",width/2,posY+ HSpace*18,Style.CT);
            
            g.drawImage(trans,0,height-40,Graphics.LEFT | Graphics.TOP);
            g.drawImage(transTop,0,0,Graphics.LEFT | Graphics.TOP);
            
            g.setColor(192,192,192);
            g.drawString("Back",width-20,height - 20,Style.CT);  
            
            

            posY--;
            if(posY<-290)
            {            	
            	stop();
            }
            
            flushGraphics();
            isDrawing=false;
        }
    }

    protected void keyRepeated(int keyCode)
    {

    }
    protected void keyPressed(int keyCode)
    {
        int gameAction = KeyMapping.getGameKey(keyCode);

        if(gameAction == Canvas.GAME_B)
        {
        	stop();
        	GameMIDlet.midlet.stopSound();
            disp.setCurrent(last);  //返回封面
            GameMIDlet.midlet.clearObj(this);
        }
    }    
}

⌨️ 快捷键说明

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