jeudi 19 novembre 2015

Collision with Bitmap AS3

So I created a nice collision system shown here. Now I have my own character sprite, which has messed up the collision on all sides.

I've tried using the pixel perfect collision system but I have a problem with it:

It only detects collision right at the edge, as you can see in the video, the ball can go slightly in front and behind the wall like it wasn't just a flat plane.

code responsible for the current collision (it did have some other stuff but that's been removed):

    for each (var wall in Walls)
    {
        if (wall.hitTestPoint(Character.x, Character.y, true)) //col right
        {
            Character.x+=CharacterSpeed;
        }
        if (wall.hitTestPoint(Character.x, Character.y, true)) //col left
        {
            Character.x-=CharacterSpeed;
        }
        if (wall.hitTestPoint(Character.x , Character.y, true)) //col bottom
        {
            Character.y+=CharacterSpeed;
        }
        if (wall.hitTestPoint(Character.x, Character.y, true)) //col top
        {
            Character.y -= CharacterSpeed;
        }
    }

Aucun commentaire:

Enregistrer un commentaire