I'm trying to make a little game for Android with LibGDX and am having a hard time with collision detection. So, I have two shapes : The first one is a rectangle (the player) :
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(Color.BLACK);
shapeRenderer.rect(position.x, position.y, width, height);
shapeRenderer.end();
The second one is the following, kind of a cage :
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(Color.BLACK);
shapeRenderer.rect(0, 0, 50, Gdx.graphics.getHeight());
shapeRenderer.rect(0, 0, Gdx.graphics.getWidth(), 50);
shapeRenderer.rect(Gdx.graphics.getWidth()-50, 0, 50, Gdx.graphics.getHeight());
shapeRenderer.rect(0, Gdx.graphics.getHeight()-50, Gdx.graphics.getWidth(), 50);
shapeRenderer.end();
My question is :
How can I detect collision between these two objects ? The only way I know, how to detect collision is with the intersect method from the Rectangle class but I would like to make more complex shapes than rectangles.
Thank you for your help !