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

时间:2015-09-30 20:25:48

标签: haxe haxeflixel

拿这段代码:

\s+

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(); } 是通过引用传递还是被复制?

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

1 个答案:

答案 0 :(得分:5)

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