Hi GDevvers!
Any advice on this is greatly appreciated:
There are different types of cards in my deckbuilder game, each of which can be upgraded several times. For example, upgrading a ‘Movement card’ will add +1 tile to the distance this card is able to move the player on a grid of tiles. Upgrading an ‘Action card’ will add +1 to its (attack/debuff/…) power.
To visualize the different kinds of upgrades on the cards themselves, my thinking has been to construct the card objects from different assets of the same size, and layering them on top of each other using the Sticker behavior, as well as linking them (and even using Object Grouping) to keep them together. This has created several issues with scaling and tweening (described below).
This is the way a card is layered:
- The “Base layer”, which is simply a white card with a black outline. This layer has Draggable behavior, and all the other layers are Stuck to it (with the Sticker behavior):
- The “Subtype layer”, which is a layout for the type of card (with much transparency), to which is stuck:
- The “Title layer”, which contains the card’s name and image, to which is stuck:
- One or more “Mask layers”, which I use for collisions when combining cards (this is a mechanic) or dropping them on a grid (moving the player — another mechanic)
These layers also all have the Tween behavior. Here’s a part of the code to show the layering:
In various situations, I need to change the scale of the card (when it’s dragged onto the tile grid for example), and/or its position (when the player ‘misdrops’ a card, tweening it back to the correct position in the player’s hand).
The main problem I have is with this tweening & scaling, and keeping all these layers the same size and in the same position, overlapping exactly with each other. No matter what I try, the layers don’t scale/tween consistently with each other. It doesn’t seem to matter if I tween and scale them simultaneously or change (set) the scale first (so not tweening it) and then tween the position. Tween times are the same for scaling and changing positions, and I delete all tweens when they’re finished.
Main Question:
Should I approach the (creation/manipulation of) card objects differently? What would be best practice here? Would love to hear from anyone who knows how to best approach this, as I am a little bit at wit’s end… ![]()
