如何在吃豆子游戏中进行墙壁碰撞? (绿脚)

问题描述 投票:0回答:0

我想制作 Pacman 游戏,但我对此很困惑,而 greenfoot 不支持检测合并的透明图像对象。

我尝试使用 getColorAt() 但我尝试使用 getColorAt() 但导入到 greenfoot 的图像是过滤器中的颜色(颜色变化)。即使我已经确认我拥有的墙对象是颜色 (33, 33, 255)

这是我吃豆子的代码

actor map = getOneIntersectingObject (map.class);
if (Greenfoot.isKeyDown("up")) {
    setLocation(getX(), getY() - 4);
    if (map.getImage().getColorAt(getX(), getY()).equals(new Color(33, 33, 255))) {
        setLocation(getX(), getY()+4)
    }
}

我尝试将地图编辑为透明然后将图像代码更改为 我尝试将地图编辑为透明然后将颜色碰撞代码更改为 RGBA (0, 0, 0, 0) 但它仍然没有

我应该把地图的一部分 1 1 1 地切割吗?

java collision-detection game-physics pacman greenfoot
© www.soinside.com 2019 - 2024. All rights reserved.