Structuring game objects

Hi,

Quite new with defold and would love some advice.

I have a “board” game object. It has a script to fill the screen with another game object, “gem”, via a factory. Those gems are clickable. When clicked, they change color, rotate, scale, and display a score for a few seconds.

I have three questions that probably don’t have real answers, but preferences.

  1. Should I create independent components (audio, sprite, factory, …) that I “attach” to a game object or should I define them inside the game object? The answer might be around reusability, but in general loads of tiny components or one huge game object.

  2. Similarly, one script vs many? From other posts, it seems one script and many lua modules is preferred.

  3. Lastly, filling the screen with gems had me increase many limits (max game object, max sprite, max audio, …). Is this to be expected?

Thank you for your help

1 Like

Both approaches will work, but I’d be wary of trying to create too many small objects that need to communicate via message passing unnecessarily.

Yes, the defaults are set low to not waste memory. You are supposed to increase them to values which works well for your game.

1 Like

Great to hear

Thank you

Just one clarification if possible

I display a score when gems are clicked. The overall look I am going for is similar to hit points.

Currently, I have a label on the gem. This greatly couples the gem and the score, but also avoids message passing.

Would it be better to send a message and use a factory?