如何获取精灵“表”中精灵的大小?
我的问题是在精灵“表”中获取精灵。
public class Blocks extends Sprite{
public Blocks() throws IOException
{
super(Image.createImage("/blockSprite.png"),20,30);
}
}
“blockSprite.png 包含精灵图像,一张图像中有许多精灵”
这里的问题是使用这行代码,我应该如何获取图像中的精灵大小/尺寸?
精灵表:
宽度 - 162
高度 - 280
我想知道表单中精灵的宽度/高度?以及如何确定 Sprite Sheet 中精灵的宽度/高度?
my problem is getting the Sprite in a Sprite "Sheet".
public class Blocks extends Sprite{
public Blocks() throws IOException
{
super(Image.createImage("/blockSprite.png"),20,30);
}
}
"the blockSprite.png contains images of Sprites, many sprites in 1 image"
The problem here is using this line of code, how I am supposed to get the Sprite size/dimension in the image?
Sprite Sheet:
Width - 162
Height - 280
I want to know the width/height of the sprites in the sheet? and how to determine the width/height of the sprites in a Sprite Sheet?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你知道每行每列有多少个精灵吗?然后将宽度除以一列中有多少个精灵,将高度除以一行中有多少个精灵。
(我可能会弄错列和行,我不是英语母语,但如果第一次尝试没有成功,你应该切换行/列)
You do know how many sprites are there in each row and column right? then just divide the width with how many sprites are there in a column and divide the height with how many sprites are there in a row.
(I may get the column and row wrong, I'm not native English, but you should just switch the row/column if the first try didn't work out)
一种方法是使用图像编辑软件(比如 GIMP,它是免费的)。
你需要做的是,
精灵。
之后,只需使用 https://developer .mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images#Slicing。
玩得开心!!
One way is to use an image editing software (say GIMP, its free).
What you have to do is,
sprite.
After that, just use https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images#Slicing.
Have fun!!