當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.createBufferStrategy方法代碼示例

本文整理匯總了Java中java.awt.Canvas.createBufferStrategy方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.createBufferStrategy方法的具體用法?Java Canvas.createBufferStrategy怎麽用?Java Canvas.createBufferStrategy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.Canvas的用法示例。


在下文中一共展示了Canvas.createBufferStrategy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Window

import java.awt.Canvas; //導入方法依賴的package包/類
public Window(KTech gc) {
	image = new BufferedImage(gc.getWidth(), gc.getHeight(), BufferedImage.TYPE_INT_RGB); //Passes through the width and height
	
	canvas = new Canvas();
	Dimension s = new Dimension((int)(gc.getWidth() * gc.getScale()), (int)(gc.getHeight() * gc.getScale()));
	canvas.setPreferredSize(s);
	canvas.setMaximumSize(s);
	canvas.setPreferredSize(s);
	
	//Setting up the JFrame
	
	frame = new JFrame(gc.getTitle());
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setLayout(new BorderLayout());
	frame.add(canvas, BorderLayout.CENTER);
	frame.pack();
	frame.setLocationRelativeTo(null);
	frame.setResizable(false);
	frame.setVisible(true);
	
	canvas.createBufferStrategy(1);
	bs = canvas.getBufferStrategy();
	g = bs.getDrawGraphics();
}
 
開發者ID:dawings1,項目名稱:Side-Quest-City,代碼行數:25,代碼來源:Window.java

示例2: start

import java.awt.Canvas; //導入方法依賴的package包/類
/**
 * Starts displaying the game.
 */
public void start()
{	requestFocus();
	loop.setPanel(this);
	if(mode==0)
	{	int width = getPreferredSize().width;
		int height = getPreferredSize().height;
		image = createImage(width, height);
	}
	else if(mode==1)
		image = createVolatileImage();
	else if(mode==2)
	{	Canvas canvas = new Canvas();
		canvas.setPreferredSize(getPreferredSize());
		add(canvas);
		canvas.createBufferStrategy(2);
		bufferStrategy = canvas.getBufferStrategy();
	}
}
 
開發者ID:vlabatut,項目名稱:totalboumboum,代碼行數:22,代碼來源:LoopPanel.java

示例3: create

import java.awt.Canvas; //導入方法依賴的package包/類
public static void create(int width, int height, String title, int _clearColor, int numBuffers) {

		if (created)
			return;

		window = new JFrame(title);
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		content = new Canvas();

		Dimension size = new Dimension(width, height);
		content.setPreferredSize(size);

		window.setResizable(false);
		window.getContentPane().add(content);
		window.pack();
		window.setLocationRelativeTo(null);
		window.setVisible(true);

		buffer = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
		bufferData = ((DataBufferInt) buffer.getRaster().getDataBuffer()).getData();
		bufferGraphics = buffer.getGraphics();
		((Graphics2D) bufferGraphics).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		clearColor = _clearColor;

		content.createBufferStrategy(numBuffers);
		bufferStrategy = content.getBufferStrategy();

		created = true;

	}
 
開發者ID:TheByteGuru,項目名稱:Tanks_Tutorial,代碼行數:31,代碼來源:Display.java


注:本文中的java.awt.Canvas.createBufferStrategy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。