Is it possible to create collision object at runtime?

I’m new to Defold, and try to create a brick game for learning purpose.

I plan to bounce the ball if it hits the edges of window (left, right, top, bottom).
So I placed four boxes at the edges, and bounce the ball if a hit message is posted.
That works great, but now I want to adapt the window size, so the collision object cannot be placed at fixed positions, so I figure I could create those boxes inside collision object at runtime.

But after a wide search on both Defold document, forum and google, I cannot find anything tell me how to create new collision shape inside collision object.

Here I come, is it possible? Or is there any “adapt” screen size solution?

To clarify, I think you’ve asked two different questions:

I believe you can’t.

But this you can do!

Just create objects using a factory.


And as for this:

Well that depends on you. Do you want your game to stretch and shrink to fill the display? Or do you want the aspect ratio to stay the same and have black borders on the edges? Or do you want just more of the game to be visible on larger screens?

I suggest you read through this: The render pipeline in Defold

2 Likes