当前位置: 首页>>代码示例>>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;未经允许,请勿转载。