For anyone wondering, the work flow I'm using is:
$ cd ~/devkit/projects/
$ basil init <game-name>
Create a coffeescript directory:
$ mkdir ~/devkit/projects/<game-name>/coffee
Watch and auto-compile coffeescript to js and copy to the projects /src directory
$ cd ~/devkit/projects/<game-name>/coffee
$ coffee --watch --compile --output ../src/ .
Run sdk web frontend
$ basil serve
Start hacking at your application.
$ emacs ~/devkit/projects/<game-name>/coffee/Application.coffee
And here is 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.View as View` | |
`import animate` | |
toColor = (x) -> (x % 255).toString(16) | |
class Trail extends GC.Application | |
createTrail: (pt) -> | |
opts = merge(pt, {superview: GC.app.view}) | |
new TrailBox(pt, opts) | |
initUI: -> | |
@style.backgroundColor = '#FFFFFF' | |
@view.on('InputMove',(evt,pt) -> @.createTrail(pt)) | |
launchUI: -> #disable splash screen | |
class TrailBox extends View | |
init: (opts) -> | |
colorZ = toColor(opts.x + opts.y) | |
colorX = toColor(opts.x) | |
colorY = toColor(opts.y) | |
options = merge(opts, { | |
backgroundColor: '#'+ colorZ + colorX + colorY | |
opacity: 0.8 | |
anchorX: 1.5 | |
anchorY: 1.5 | |
width: 3 | |
height: 3 | |
r: 0 }) | |
super options | |
fadeAnimation = { | |
opacity: 0 | |
x: opts.x - 15 | |
y: opts.y - 15 | |
anchorX: 15 | |
anchorY: 15 | |
width: 30 | |
height: 30 | |
r: Math.PI * 4} | |
animate(@).now(fadeAnimation, 1500).then(@.remove()) | |
remove: -> | |
=> @.removeFromSuperview() | |
`exports = Trail` |
No comments:
Post a Comment