Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better skeletons

  • Loading branch information...
commit 999305404b0af74d699b400cf83b7fd2d2b7cd7b 1 parent deb3a87
@ryanwilliams authored
View
2  package.json
@@ -18,7 +18,7 @@
, "url": "https://github.com/ryanwilliams/cocos2d-javascript/blob/master/LICENSE"
}]
-, "dependencies": { "jah": "0.3.0"
+, "dependencies": { "jah": ">= 0.4.0"
}
, "preferGlobal": true
View
14 skeletons/cocos2d-coffee/Cakefile
@@ -1,14 +0,0 @@
-{print} = require 'sys'
-{exec, spawn} = require 'child_process'
-
-task 'build', 'Build project from src.coffee/*.coffee to src/*.js', ->
- exec 'coffee --compile --output src/ src.coffee/', (err, stdout, stderr) ->
- throw err if err
- console.log stdout + stderr
-
-task 'watch', 'Watch src.coffee/ for changes', ->
- coffee = spawn 'coffee', ['-w', '-c', '-o', 'src', 'src.coffee']
- coffee.stderr.on 'data', (data) ->
- process.stderr.write data.toString()
- coffee.stdout.on 'data', (data) ->
- print data.toString()
View
1  skeletons/cocos2d-coffee/jah.json
@@ -1,4 +1,5 @@
{ "jahProject": { "version": "${jahVersion}" }
+, "compileCoffee": true
, "libs": ["cocos2d"]
, "externalize": { "cocos2d": "cocos2d.js"
, "jah": "cocos2d.js"
View
2  skeletons/cocos2d-coffee/package.json
@@ -2,7 +2,7 @@
"name": "${appname}",
"author": "",
"description": "",
- "version": "0.0.1",
+ "version": "0.1.0",
"homepage": "",
"engines": {
View
29 skeletons/cocos2d-coffee/src.coffee/${classname}.coffee
@@ -1,29 +0,0 @@
-# Pull in the modules we're going to use
-cocos = require 'cocos2d' # Import the cocos2d module
-nodes = cocos.nodes # Convenient access to 'nodes'
-geo = require 'geometry' # Import the geometry module
-
-# Convenient access to some constructors
-Director = cocos.Director
-Label = nodes.Label
-Layer = nodes.Layer
-Point = geo.Point
-
-class @${classname} extends Layer
- constructor: ->
- # You must always call the super class constructor
- super
-
- # Get size of canvas
- s = Director.sharedDirector.winSize
-
- # Create label
- label = new Label string: '${appname}'
- , fontName: 'Arial'
- , fontSize: 67
-
- # Position the label in the centre of the view
- label.position = new Point s.width / 2, s.height / 2
-
- # Add label to layer
- @addChild label
View
32 skeletons/cocos2d-coffee/src/${filename}.coffee
@@ -0,0 +1,32 @@
+# Import in the modules we're going to use
+cocos = require 'cocos2d'
+nodes = cocos.nodes
+geo = require 'geometry'
+
+# Convenient access to some constructors
+{Director} = cocos
+{Label, Layer} = nodes
+{Point} = geo
+
+class ${classname} extends Layer
+ constructor: ->
+ # You must always call the super class constructor
+ super
+
+ # Get size of canvas
+ size = Director.sharedDirector.winSize
+
+ # Create label
+ label = new Label
+ string: '${appname}'
+ fontName: 'Arial'
+ fontSize: 67
+
+ # Position the label in the centre of the view
+ label.position = new Point size.width / 2, size.height / 2
+
+ # Add label to layer
+ @addChild label
+
+# Export the class so it can be accessed from outside this file
+@${classname} = ${classname}
View
17 skeletons/cocos2d-coffee/src.coffee/main.coffee → skeletons/cocos2d-coffee/src/main.coffee
@@ -1,14 +1,15 @@
-# Pull in the modules we're going to use
-cocos = require 'cocos2d' # Import the cocos2d module
-nodes = cocos.nodes # Convenient access to 'nodes'
-events = require 'events' # Import the events module
-geo = require 'geometry' # Import the geometry module
+# Import in the modules we're going to use
+cocos = require 'cocos2d'
+nodes = cocos.nodes
+events = require 'events'
+geo = require 'geometry'
# Convenient access to some constructors
-Director = cocos.Director
-Scene = nodes.Scene
+{Director} = cocos
+{Scene} = nodes
-${classname} = require('./${classname}').${classname}
+# Import our class
+{${classname}} = require './${filename}'
# Initialise application
@main = ->
View
42 skeletons/cocos2d-standard/src/${filename}.js
@@ -0,0 +1,42 @@
+"use strict" // Use strict JavaScript mode
+
+// Import in the modules we're going to use
+var cocos = require('cocos2d')
+ , nodes = cocos.nodes
+ , geo = require('geometry')
+
+// Convenient access to some constructors
+var Director = cocos.Director
+ , Label = nodes.Label
+ , Layer = nodes.Layer
+ , Point = geo.Point
+
+/**
+ * @class Initial application layer
+ * @extends cocos.nodes.Layer
+ */
+function ${classname} () {
+ // You must always call the super class constructor
+ ${classname}.superclass.constructor.call(this)
+
+ // Get size of canvas
+ var size = Director.sharedDirector.winSize
+
+ // Create label
+ var label = new Label({ string: '${appname}'
+ , fontName: 'Arial'
+ , fontSize: 76
+ })
+
+ // Position the label in the centre of the view
+ label.position = new Point(size.width / 2, size.height / 2)
+
+ // Add label to layer
+ this.addChild(label)
+}
+
+// Inherit from cocos.nodes.Layer
+${classname}.inherit(Layer)
+
+// Export the class so it can be accessed from outside this file
+this.${classname} = ${classname}
View
50 skeletons/cocos2d-standard/src/main.js
@@ -1,51 +1,22 @@
"use strict" // Use strict JavaScript mode
-// Pull in the modules we're going to use
-var cocos = require('cocos2d') // Import the cocos2d module
- , nodes = cocos.nodes // Convenient access to 'nodes'
- , events = require('events') // Import the events module
- , geo = require('geometry') // Import the geometry module
- , ccp = geo.ccp // Short hand to create points
+// Import in the modules we're going to use
+var cocos = require('cocos2d')
+ , nodes = cocos.nodes
+ , events = require('events')
+ , geo = require('geometry')
// Convenient access to some constructors
-var Layer = nodes.Layer
- , Scene = nodes.Scene
- , Label = nodes.Label
+var Scene = nodes.Scene
, Director = cocos.Director
-/**
- * @class Initial application layer
- * @extends cocos.nodes.Layer
- */
-function ${classname} () {
- // You must always call the super class constructor
- ${classname}.superclass.constructor.call(this)
-
- // Get size of canvas
- var s = Director.sharedDirector.winSize
-
- // Create label
- var label = new Label({ string: '${appname}'
- , fontName: 'Arial'
- , fontSize: 76
- })
-
- // Position the label in the centre of the view
- label.position = ccp(s.width / 2, s.height / 2)
-
- // Add label to layer
- this.addChild(label)
-}
-
-// Inherit from cocos.nodes.Layer
-${classname}.inherit(Layer)
+// Import our class
+var ${classname} = require('./${filename}').${classname}
/**
* Entry point for the application
*/
-function main () {
- // Initialise application
-
+this.main = function main () {
// Get director singleton
var director = Director.sharedDirector
@@ -65,6 +36,3 @@ function main () {
// Preload our assets
director.runPreloadScene()
}
-
-
-exports.main = main
Please sign in to comment.
Something went wrong with that request. Please try again.