Graphics2D要播放的copyArea方法的awt端口



我正在将一个旧的awt-java游戏移植到playn框架中,我有一些graphics.copyArea电话。。有办法将此呼叫映射到一些play.core。Canvas呼叫?

感谢

您应该能够使用与Canvas.drawImage调用的源和目标相同的画布:

CanvasImage image = graphics().createImage(100, 100);
// draw stuff in your canvas image
// define the source of the copyArea: 15x15+5+5
float sx = 5, sy = 5, swidth = 15, sheight = 15;
// note that we use swidth/sheight for dwidth/dheight because we don't want to scale,
// we just want to copy data from one place in the image to another
image.canvas().drawImage(image, 25, 25, swidth, sheight, sx, sy, swidth, sheight);

然而,如果你真的在每一帧上都将所有内容渲染到画布上,你可能会发现这非常慢。您最好重新构建东西,使用ImageLayer和其他可以加速硬件的构造。

最新更新