Take this code:
function createGUIHud():Void
{
this.screen.gameHud = new NormalGameHud(10, 0, this.screen.getTextureAtlas());
this.screen.gameHud.x = FlxG.width - (this.screen.gameHud.width + GameSize.getPositionByPlatform(10));
this.screen.gameHud.y = GameSize.getPositionByPlatform(10);
}
// NormalGameHud.hx
public function new(lives:Int = 10, corn:Int = 0, textureAtlas:SparrowData)
{
super(0, 0, 30);
this.lives = lives;
this.cornCount = corn;
this.textureAtlas = textureAtlas;
this.createScoreboard();
this.createLivesCount();
this.createCornCounter();
}
Does textureAtlas
get passed by reference or does it get copied?
I know PHP passes objects by reference, and things like Arrays get copied unless stated otherwise (prefixed with &
). Does the same apply with Haxe?
AFAIK, Basic Types (Int
, Float
, Bool
) are passed by value. Everything else is passed by reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With