From a8cce43e9157749ce83862aee1561a106b2c335b Mon Sep 17 00:00:00 2001 From: Marcel W Date: Mon, 17 Nov 2014 17:23:04 +0100 Subject: [PATCH 1/2] Integrating grunt-contrib-copy and grunt-contrib-clean to provide a more comfortable way to work with the the phaser template, especially for beginners. Reference to assets is ../assets/[...] in src, as well as in deploy code. --- GruntFile.js | 28 +++++++++++++++++++++++++--- package.json | 4 +++- src/assets/assets_here | 0 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 src/assets/assets_here diff --git a/GruntFile.js b/GruntFile.js index 149e422..40876c7 100644 --- a/GruntFile.js +++ b/GruntFile.js @@ -3,9 +3,17 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-open'); grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-clean'); grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), + + clean: { + assets: ["deploy/assets"], + js: ["deploy/js/*.js", "!deploy/js/*.min.js"] + }, + connect: { server: { options: { @@ -23,9 +31,23 @@ module.exports = function (grunt) { } }, watch: { - files: 'src/**/*.js', - tasks: ['concat'] + source: { + files: 'src/**/*.js', + tasks: ['clean:js', 'concat'] + }, + assets: { + files: 'src/assets/*.*', + tasks: ['clean:assets', 'copy'] + } }, + copy: { + files: { + cwd: 'src/assets', + src: '**/*', + dest: 'deploy/assets', + expand: true + } + }, open: { dev: { path: 'http://localhost:8080/index.html' @@ -33,6 +55,6 @@ module.exports = function (grunt) { } }); - grunt.registerTask('default', ['concat', 'connect', 'open', 'watch']); + grunt.registerTask('default', ['clean', 'concat', 'copy', 'connect', 'open', 'watch']); } \ No newline at end of file diff --git a/package.json b/package.json index af3b134..a8f7a64 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,8 @@ "grunt": "~0.4.2", "grunt-contrib-concat": "~0.3.0", "grunt-contrib-watch": "~0.5.3", - "grunt-contrib-connect": "~0.6.0" + "grunt-contrib-connect": "~0.6.0", + "grunt-contrib-copy": "~0.7.0", + "grunt-contrib-clean": "~0.6.0" } } \ No newline at end of file diff --git a/src/assets/assets_here b/src/assets/assets_here new file mode 100644 index 0000000..e69de29 From 8b7687d1006086ae1e583a015b481ffb34ff3894 Mon Sep 17 00:00:00 2001 From: Marcel W Date: Mon, 17 Nov 2014 17:23:16 +0100 Subject: [PATCH 2/2] Cleaned up main.js (not the way to go, just my personal taste) --- src/game/main.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/game/main.js b/src/game/main.js index 8221f84..104d270 100755 --- a/src/game/main.js +++ b/src/game/main.js @@ -1,30 +1,18 @@ -/** - * - * This is a simple state template to use for getting a Phaser game up - * and running quickly. Simply add your own game logic to the default - * state object or delete it and make your own. - * - */ - var state = { init: function() { - // Delete this init block or replace with your own logic. - - // Create simple text display for current Phaser version - var text = "Phaser Version "+Phaser.VERSION + " works!"; + var text = "Phaser Version " + Phaser.VERSION + " works!"; var style = { font: "24px Arial", fill: "#fff", align: "center" }; var t = game.add.text(this.world.centerX, this.world.centerY, text, style); t.anchor.setTo(0.5, 0.5); - - }, + }, preload: function() { - // STate preload logic goes here + }, create: function(){ - // State create logic goes here + }, update: function() { - // State Update Logic goes here. + } };