I’m making a simple card game to teach myself about custom resources but I’m having some trouble getting my head around them.
My plan is to use custom resources to create each card, so I have 52 unique resources, each of them has a name, a value, and a sprite. I have these resources in an array called “deck.”
What I’m having trouble understanding is how exactly I attach those custom resources to actual nodes or objects that I can see and manipulate in game. My idea is to just have one card template and instantiate it however many times, while assigning it a random resource from the deck. But I’m not sure how I would do that or even if that’s the best way to approach it. Any help would be appreciated.
I understand that, but what I don’t understand is how I would actually instantiate the card objects with the data from the resource. They are just resources, they’re not attached to a node, so I’m struggling to understand how to create objects with them.
Hard to say without some code. Resources have no control over the SceneTree, so it won’t be them creating the Node objects. I figure you would have a CardManager/Deck node with a array of Resources, when it’s time to draw the Deck would pop a random resource, create a card, and give the new card it’s resource or fill in info based on the resource.
Then I have a card template called “card_temp” and it has a reference to the custom resource as an export variable, and the same variables as the card class:
And this is where I get stuck. I can instantiate the card template but I don’t know how to give it the resource values. There’s something I’m missing here and I don’t know what.