class extends not working as expected.
-
I have a player class
class Player extends FlxSprite
where the coin class extends the player class. In the coin class i have a var...public static var _total:Int = 0;
. within the players class, when i typethis.coin.
_total is not displayed. I have also tried by reference to the player class,player.coin.
. what am i doing wrong?also, i have a flxBar
Bar.setRange(player.coins.countDead(), player.coins.countLiving());
this will give an error because i am using a function and not an int, but is there another way to get this to work the easy way?
-
You want to do something like this for static properties:
//somewhere in your Player class public function pickupCoin():Void { Coin._total++; //play animations, sounds, etc. }
Instances can't access static properties, so you use the full class name instead
-
Actually, you can access static properties - if you do it from inside the same class.
-
@starry-abyss said in class extends not working as expected.:
Actually, you can access static properties - if you do it from inside the same class.
Yeah, this too