This site requires JavaScript, please enable it in your browser!
Greenfoot back
SnapDraggen
SnapDraggen wrote ...

2016/4/18

Prevent Collision With Transparent Object

SnapDraggen SnapDraggen

2016/4/18

#
Hey, I need help on a Pacman game I'm working on. I want a want to make a Pacman track without making individual blocks. I took the below image and made everything but the walls transparent: With my collision system:
    public void checkCollision()
    {
        Walls a = (Walls) getOneIntersectingObject(Walls.class);
        if (a != null) {
            w = 2;
            x = 2;
            y = 2;
            z = 2;
            move(-6);
        }
    }
It always thinks its colliding with the walls since it is one image. I would like to know if there is a way I could make the Pacman only collide with the walls. Thanks in advance!
danpost danpost

2016/4/18

#
I would suggest using what is called perfect pixel collision, which checks the color of the map. I do not know if this is possible with your scenario and it is quite elaborate and CPU time consuming. Better might be to add transparent Intersection objects that tell the actors which directions are available at its location. One at each possible turn location is all that is required.
You need to login to post a reply.