Turning bronze coins to gold
You may notice that your gold coins in the scene editor show up as bronze coins in the game. This is because the Coin
class defaults to using the bronze texture and value. We will specify our gold coins by setting their name attribute to gold in the scene editor and then checking for this name in the Coin init
function. Follow these steps to implement golden coins:
Open your encounters in the scene editor, select your gold coins, and use the Attributes inspector to set the name value of each node to
gold
, as shown here:We can easily loop through all nodes with a certain name. We will use this functionality to run the
Coin
class'sturnToGold
function on any node with the namegold
. OpenEncounterManager
and add the following code in theinit
function, at the bottom of the encounterfor
loop (new code in bold):// Save initial sprite positions for this encounter: saveSpritePositions(node: encounterNode) // Turn golden coins gold...