问题描述
我正在制作一个游戏,其中一些物体旋转以面对它们正在射击的物体.拍摄之间有延迟,我希望物体一直面向它所在的位置,直到再次拍摄.我知道如何加载图像,也知道如何使用 AffineTransform 旋转它们.但是有了这个,我需要在每次绘制对象时计算旋转.
I'm making a game where some objects rotate to face what they're shooting at. There's a delay in between shooting and I want the object to keep facing where it is until it shoots again. I know how to load images and I know how to rotate them using AffineTransform. But with this I need to calculate the rotate every time the object gets drawn.
所以我的问题是如何旋转图像并将结果保存到可以显示的新图像中?
So my question is how can I rotate an image and save the result into a new image that would get displayed?
推荐答案
如何旋转图像并将结果保存到可以显示的新图像中?
创建一个新的 BufferedImage.获取 Graphics 对象(通过 BufferedImage.getGraphics(). 将旋转后的图像绘制到这个缓冲图像上,并将图像保存在数组或基于它的旋转(以便在需要时轻松查找).
Create a new BufferedImage. Get hold of a Graphics object (through BufferedImage.getGraphics(). Paint the rotated image onto this buffered image, and save the image in an array or a map based on its rotation (so that it easy to look it up when you need it).
这篇关于Java2D - 如何旋转图像并保存结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)