I'm making a game that'll have options to upgrade, and in turn, earn more money. I thought it'd be easiest to make a sprite for every building, and different animations for each "upgrade". But if someone makes two of the same building, and then upgrades one, both sprites will change to the upgraded animation.
My game has 36 spots for buildings, and the player can build whatever they want. Is there any way to make it so only the clicked sprite's animation changes?
If this has been asked before, please forgive me and help me find the post. I, for the life of me, can't find this answer anywhere.
Develop games in your browser. Powerful, performant & highly capable.
You need a way to differentiate the two buildings. I'd recommend an instance variable for each spot or building. Then, when a building is clicked, you can tell which has been selected. Hopefully this simplistic example helps:
There may also be a solution that uses the buildings UID's, but I don't have much experience there.