How to implement collisions in my top down 2d game

Sorry for asking a broad question, I am relatively new to defold and, despite researching for hours, I cannot figure out how to implement collisions in my top down 2d game. All the content I have come across has been based on platformer games and involve gravity, and my very limited knowledge on defold does not allow me to adapt the code.

So, I have a top down view 2d game. I have a player object, and I would like to make a program/system where, if the player collides with a wall or game prop, it cannot move through it.

I’m not necessarily asking for code, but I was wondering if there were necessary steps I must take to allow me to program this.

Many thanks

The collision resolution for a platformer game and a top-down game is basically the same. When you detect one or more points of collision you separate the objects using the same algorithm:

You also have a simple example here with a more naive approach to collision resolution:

CODE: https://github.com/britzl/publicexamples/tree/master/examples/rotate_and_move
DEMO: Rotate and Move 0.0

Thanks for the resources! The code behing collisions makes much more sense now.

Although now, I am having trouble understanding where to place collision objects etc. Am I right in thinking a collision object goes into both the player and tilemap layer?

Thank you! I managed to tinker with it a little and, using the resources you provided, I managed to make it work!

Yes, one collision object on the player game object and one on the game object with the tilemap (using the tilemap itself as a shape).