CAAT(1)
チュートリアルに載ってるサンプルコード(Page not found · GitHub Pages)をCoffeeScriptで書きなおしてみた
test-caat.coffee(test-caat.jsにコンパイルされる)
class Circle extends CAAT.ShapeActor constructor: -> super @setLocation(20,20) @setSize(60,60) @setFillStyle('#ff0000') @setStrokeStyle('#000000') class TheGame extends CAAT.Director constructor: (w, h, id) -> super @initialize(w, h) scene = @createScene() scene.addChild(new Circle) CAAT.loop(1) window.onload = -> new TheGame(100, 100)
test-caat.html
<!DOCTYPE html> <html> <head> <script src="caat.js" type="text/javascript"></script> <script src="test-caat.js" type="text/javascript"></script> </head> <body> </body> </html>
body中に書けばwindow.onloadへの登録は不要
クラス化のやり方はこれが適切なのかはわからない