swift - Integer value not updating -
i creating game , trying keep record of enemy's killed sklabel node not updating. here's how i'm implementing
class gamescene: skscene, skphysicscontactdelegate { var enemy1killcounter:int = 0 var enemy1killcounterlabel = sklabelnode () override func didmovetoview(view: skview) { createenemykilledlabel() } func createenemykilledlabel() { enemy1killcounterlabel.text = "\(enemy1killcounter)" enemy1killcounterlabel.fontsize = 65 enemy1killcounterlabel.fontcolor = skcolor .blackcolor() enemy1killcounterlabel.position = cgpointmake(400, 400) self.addchild(enemy1killcounterlabel) } func updateenemy1killcounter() { enemy1killcounter = enemy1killcounter + 1 print(enemy1killcounter) } // use next method because call method in enemy class when enemy "killed" func enemy1dieg () { updateenemy1killcounter() }
does know why label not being updated?
when update enemy1killcounter
, need update enemy1killcounterlabel.text
new value. besides, don't see createenemykilledlabel()
called. make sure called somewhere.
a side note - variable names typically start lowercase, enemy1killcounterlabel
. following standards makes code easier read others...