Inherit from GameObject?

Hi,

I’m trying to create a card game, where I have different cards, which all have the same back sprite, the same flip animation script, but different front sprites (and some other properties like ‘value’).

My plan was to have a base card object, and have all my cards inherit from that, and then set the front sprite and specific properties for each card in the respective inherited object.

In Godot for example I can inherit one scene from another, which makes it easy to have the same general object, but with different properties, sprites, etc.

I’m note quite sure how to do it in Defold, as I understand there is no inheritance.
Preferably I would like to do it in design time, so that I can see and edit each card in the editor.

How would you go about sth. like this?

Kind regards.

1 Like

im pretty sure you dont even need to create different game objects for this, just have one and instance it (use it) as much as you want. Most of the work should be on the lua/script side of things:

this function can set any property of any Game object, including a sprite component, of which you can have as many as you want in a game object

1 Like

Thanks, that pretty much was it. :slight_smile:

I needed to create the cards through a factory anyway, so I have now one game object, which changes its sprite dynamically on creation, based on its value.

1 Like