Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.85k stars 819 forks source link

Using Starling with Haxe, compilation issue #871

Closed alamboley closed 8 years ago

alamboley commented 8 years ago

Hey Daniel, while trying to use Starling with Haxe, I run into several issues. Haxe compiler is more strict than ActionScript one:

starling/library.swf@starling.core.Starling:1: character 0 : Same field name can't be use for both static and instance : context
starling/library.swf@starling.core.Starling:1: character 0 : Same field name can't be use for both static and instance : frameID
starling/library.swf@starling.core.Starling:1: character 0 : Same field name can't be use for both static and instance : juggler
starling/library.swf@starling.core.Starling:1: character 0 : Same field name can't be use for both static and instance : contentScaleFactor
starling/library.swf@starling.core.Starling:1: character 0 : Same field name can't be use for both static and instance : painter
starling/library.swf@starling.display.MeshBatch:1: character 0 : Redefinition of variable numIndices in subclass is not allowed. Previously declared at starling.display.Mesh
starling/library.swf@starling.display.MeshBatch:1: character 0 : Redefinition of variable numVertices in subclass is not allowed. Previously declared at starling.display.Mesh

It seems it doesn't like the same naming in a class, like:

public static function get juggler():Juggler { return sCurrent ? sCurrent._juggler : null; }

public function get juggler():Juggler { return _juggler; }

I know this won't be an easy fix since it will break compatibility. Perhaps there is a fix on the Haxe side...

PrimaryFeather commented 8 years ago

Hm, hm, hm ... that's a bummer.

You're right, changing those static property names is out of the question — a lot of code depends on that. Of course, I can also understand that it's unlikely that this will be changed in Haxe anytime soon. 😐

My recommendation is to make that change in a branch of yours and always merge the Starling master back into that branch before using it with Haxe. That works surprisingly well normally.

As for the specific changes, I'd name those static properties Starling.currentJuggler (etc.) or remove them altogether, since they are only provided for convenience.

As for the last two errors, I'm a little confused — I can't find that redefinition inside MeshBatch. Do you have a code line for this error?

PrimaryFeather commented 8 years ago

(In any case, if that last two errors point are private members, that's probably something I could change.)

alamboley commented 8 years ago

Finally I found a way to solve it in Haxe http://labe.me/en/blog/posts/24838117737.html#.V0bFwGZu8yN

I created a patch with:

-starling.core.Starling.context
-starling.core.Starling.frameID
-starling.core.Starling.juggler
-starling.core.Starling.contentScaleFactor
-starling.core.Starling.painter
-starling.display.MeshBatch.numIndices
-starling.display.MeshBatch.numVertices
PrimaryFeather commented 8 years ago

Perfect! :smile: