如何在画布上将图片用作游戏角色? [英] How do I have a picture act as a game character on top of a canvas?

查看:76
本文介绍了如何在画布上将图片用作游戏角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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.

推荐答案

在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.

这篇关于如何在画布上将图片用作游戏角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆