Read more on our blog:
Wow! This is awesome, and also seems like a big deal. I remember when I first saw Haxe hello-world with everything in classes and reflexively thought, âoh, like Javaâ.
Would be great to showcase module-level fields in the âA Taste of Haxeâ code block on the front page of <haxe.org>.
Are there any plans for module level variables?
Oh, the example there shows a final
, but not a var
. I assume that module-level vars are supported as well (since âfieldsâ means both functions and variables).
Oops, somewhy my brain replaced âfieldsâ with âfunctionsâ while reading and I didnât even notice the final there.
Iâm really happy about this feature
itâs would be better if support inline for main()
inline function main()
import global.cc.Component;
import global.cc.Label;
var label:Label;
var text:String;
function onPreLoad() {
trace('onpreload');
}
function onLoad() {
trace(js.Lib.nativeThis);
label = cast js.Lib.nativeThis.label;
text = cast js.Lib.nativeThis.text;
label.string = text;
}
function update() {}
function onDisable() {}
function main() {// I hope support inline here
global.Cc.Class({
name: "fuck",
'extends': Component,
properties: {
label: {
'default': null,
type: Label
},
// defaults, set visually when attaching this script to the Canvas
text: text
},
onLoad: onLoad,
update: update,
onDisable: onDisable
});
}
and target js is
function Main_main() {
cc.Class({ name : "fuck", "extends" : cc.Component, properties : { label : Main_label, text : Main_text}, onLoad : Main_onLoad, update : Main_update, onDisable : Main_onDisable});
}
and what I want is only
cc.Class({ name : "fuck", "extends" : cc.Component, properties : { label : Main_label, text : Main_text}, onLoad : Main_onLoad, update : Main_update, onDisable : Main_onDisable});
instead of
function Main_main() {
cc.Class({ name : "fuck", "extends" : cc.Component, properties : { label : Main_label, text : Main_text}, onLoad : Main_onLoad, update : Main_update, onDisable : Main_onDisable});
}
//BTW, how to get âthisâ keyword of module?