Haxe是通过引用传递参数还是复制?

问题描述 投票:6回答:1

拿这个代码:

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();
}

textureAtlas是通过引用传递还是被复制?

我知道PHP通过引用传递对象,除非另有说明(以&为前缀),否则会复制像Arrays这样的东西。 Haxe同样适用吗?

haxe haxeflixel
1个回答
5
投票

AFAIK,Basic TypesIntFloatBool)按价值通过。其他所有内容都通过引用传递。

© www.soinside.com 2019 - 2024. All rights reserved.