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

📄 splashcanvas.java

📁 是sun公司做的开源项目
💻 JAVA
字号:
package org.bubblebreaker.view;

import org.bubblebreaker.model.*;
import org.bubblebreaker.config.*;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.*;
import javax.microedition.media.*;
import javax.microedition.media.control.*;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Font;

public class SplashCanvas extends GameCanvas{
	java.util.Timer timer=new java.util.Timer();
	Sprite sprite;
	LayerManager manager;
	Graphics m_g;
	public SplashCanvas()
	{
		super(true);
		try{
			m_g= getGraphics();
			//background color
			m_g.setColor(Color.YELLOW.getCode());
			m_g.fillRect(0,0,getWidth(), getHeight());

			m_g.setColor(Color.GREEN.getCode());
			m_g.fillRect(20,20,getWidth()-20, getHeight()-20);

			m_g.setColor(Color.CYAN.getCode());
			m_g.fillRect(40,40,getWidth()-40, getHeight()-40);

			m_g.setColor(Color.YELLOW.getCode());
			m_g.fillRect(60,60,getWidth()-60, getHeight()-60);

			m_g.setColor(Color.BLACK.getCode());
			m_g.drawString(""+getWidth()+","+ getHeight(), getWidth()/2, getHeight()/2,Graphics.TOP|Graphics.LEFT); 
			System.out.println("loading first image");
			Image image = Image.createImage("bubblebreaker.PNG");
			System.out.println("drawing first image");
			m_g.drawImage(image, getWidth()/2, getHeight()/2, Graphics.HCENTER|Graphics.VCENTER); 
			System.out.println("flush first image");
			flushGraphics();
			try{
				Thread.sleep(1000);
			}catch(Exception e){}

			manager = new LayerManager();
			image = Image.createImage("TitleImages.PNG");
			System.out.println("Loaded the title image : "+image+" : "+image.getWidth()+","+image.getHeight());
			sprite=new Sprite(image,142,92);
			//sprite=new Sprite(image,131,55);
			System.out.println("Loaded the sprite : "+sprite);
			manager.append(sprite);

			
			timer.scheduleAtFixedRate(new TitleBlink(this,getWidth()/2,getHeight()/2),2000,1000);
			flushGraphics();
		}catch(Exception e)
		{
			//TODO: handle this
			System.out.println("exception : "+e.getMessage());
			e.printStackTrace();
		}
	}
	class TitleBlink extends java.util.TimerTask
	{
		SplashCanvas m_splashCanvas;
		int x,y;
		boolean isBlue=false;
		public TitleBlink(SplashCanvas splashCanvas, int x, int y)
		{
			m_splashCanvas = splashCanvas;
			this.x=x;
			this.y=y;
		}
		public void run()
		{
			System.out.println("blink title");
			m_splashCanvas.sprite.nextFrame();
			Graphics g=m_splashCanvas.m_g;
			m_splashCanvas.manager.paint(g,x-71,y-46);
			flushGraphics();
		}
	}
}

⌨️ 快捷键说明

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