如何让图片在画布上充当游戏角色?
我在 JAVA 中有一个迷宫游戏,我正在为一堂课做,迷宫是在小程序中的画布上制作的,我想向我提供另一张图片(类似雕像的东西)作为游戏角色并能够通过方向键在迷宫中移动,那么如何将一个对象放置在画布上,可以移动和控制等?目前,我将雕像放在迷宫上的唯一方法是将图片的像素复制到迷宫上,所以它现在只是背景的一部分......请帮助我!我到处发帖寻求帮助,但无济于事。
I have a maze game in JAVA I'm doing for a class, the maze is made on a canvas in an applet, I wanted to have another picture provided to me (of a statue like thing) act as a game character and be able to be moved around the maze by the arrow keys, so how do I place an object on a canvas that can move around and be controlled, etc.? At the moment, the only way I could get my statue on the maze was by just copying the pixels of the picture onto the maze, so it's just part of the background now...Please help me! I've been posting everywhere looking for help to no avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 ContentPane 上方,您会发现存在一个 GlassPane。这是添加雕像图片而不弄乱背景的正确位置。
Above the ContentPane you will find that exists a GlassPane. It is the right place to add your statue picture without messing with the background.