Never wanting to touch Javascript after having discovered the wonders of CoffeeScript I took a quick look at how to get a hello-world example working with CoffeeScript & GameClojure... here's the code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`import ui.TextView as TextView` | |
class helloWorld extends GC.Application | |
initUI:-> | |
textView = new TextView({ | |
superview: @view | |
layout: "box" | |
text: "Hello, Coffee!" | |
color: "white"}) | |
super | |
`exports = helloWorld` |
- exports is backtick-escaped so as to render directly to javascript as the engine requires exports to have global scope.
- CoffeeScript's implementation of inheritance replaces GameClosures 'Class(<super class>, func...' inheritance helper function (and is much nicer IMO) as seen in their javascript implementation of hello-world.
Hopefully it's this easy with, non-trivial, GameClosure applications.
No comments:
Post a Comment