├── .editorconfig ├── .gitattributes ├── .gitignore ├── .yo-rc.json ├── LICENSE ├── README.md ├── generators ├── app │ ├── index.coffee │ ├── index.js │ └── templates │ │ ├── _gulpfile.coffee │ │ ├── _index.html │ │ ├── _package.json │ │ ├── assets │ │ ├── backgrounds │ │ │ └── starfield.jpg │ │ ├── images │ │ │ └── preloader.gif │ │ └── sprites │ │ │ └── phaser2.png │ │ ├── editorconfig │ │ ├── scripts │ │ ├── game.coffee │ │ └── states │ │ │ ├── boot.coffee │ │ │ ├── main.coffee │ │ │ ├── menu.coffee │ │ │ └── preload.coffee │ │ └── styles │ │ └── style.css ├── prefab │ ├── index.coffee │ ├── index.js │ └── templates │ │ ├── _prefabBitmapData.coffee │ │ ├── _prefabButton.coffee │ │ ├── _prefabEmitter.coffee │ │ ├── _prefabGroup.coffee │ │ ├── _prefabSprite.coffee │ │ ├── _prefabText.coffee │ │ └── _prefabTileSprite.coffee └── state │ ├── index.coffee │ ├── index.js │ └── templates │ └── _state.coffee ├── package.json └── test └── test-app.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | # Compiled source # 4 | ################### 5 | *.com 6 | *.class 7 | *.dll 8 | *.exe 9 | *.o 10 | *.so 11 | 12 | # Packages # 13 | ############ 14 | # it's better to unpack these files and commit the raw source 15 | # git has its own built in compression methods 16 | *.7z 17 | *.dmg 18 | *.gz 19 | *.iso 20 | *.jar 21 | *.rar 22 | *.tar 23 | *.zip 24 | 25 | # Logs and databases # 26 | ###################### 27 | *.log 28 | *.sql 29 | *.sqlite 30 | 31 | # OS generated files # 32 | ###################### 33 | .DS_Store 34 | .DS_Store? 35 | ._* 36 | .Spotlight-V100 37 | .Trashes 38 | ehthumbs.db 39 | Thumbs.db 40 | *.swp 41 | -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-generator": {} 3 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Ozan Kaşıkçı 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # generator-phaser-coffeescript-gulp 2 | 3 | > [Yeoman](http://yeoman.io) generator 4 | 5 | 6 | ## Getting Started 7 | 8 | ### What is Yeoman? 9 | 10 | Trick question. It's not a thing. It's this guy: 11 | 12 | ![](http://i.imgur.com/JHaAlBJ.png) 13 | 14 | Basically, he wears a top hat, lives in your computer, and waits for you to tell him what kind of application you wish to create. 15 | 16 | Not every new computer comes with a Yeoman pre-installed. He lives in the [npm](https://npmjs.org) package repository. You only have to ask for him once, then he packs up and moves into your hard drive. *Make sure you clean up, he likes new and shiny things.* 17 | 18 | 19 | ### Installation 20 | 21 | ##### Install Yeoman and Gulp 22 | 23 | ```bash 24 | npm i -g yo gulp 25 | ``` 26 | 27 | ##### Install phaser-coffeescript-gulp generator 28 | 29 | 30 | ```bash 31 | npm i -g generator-phaser-coffeescript-gulp 32 | ``` 33 | 34 | ##### Initiate generator in a directory 35 | 36 | ```bash 37 | mkdir my-game 38 | cd $_ 39 | yo phaser-coffeescript-gulp 40 | ``` 41 | 42 | ### Built-in web server with live-reload support 43 | 44 | Once the generator is initiated you are ready to run `gulp` command. 45 | Gulp will start a web server with live-reload support using [Browser-Sync](https://github.com/Browsersync/browser-sync), compile and merge coffee files. 46 | 47 | ![Gulp Demo](http://g.recordit.co/AmblNXxmN0.gif) 48 | 49 | And you are ready to start developing awesome games right away! 50 | 51 | ### Prefab Generator 52 | 53 | To generate a prefab run `yo phaser-coffeescript-gulp:prefab prefabname`. You will see the prefab choices: 54 | 55 | ![Prefab Demo](http://g.recordit.co/Yt7g7tG52m.gif) 56 | 57 | Then you can require your newly generated prefab in a state file. 58 | 59 | ### State Generator 60 | 61 | To generate a state run `yo phaser-coffeescript-gulp:state statename`. 62 | 63 | ![State Demo](http://g.recordit.co/YmGLbBKSUO.gif) 64 | 65 | ## License 66 | 67 | MIT 68 | -------------------------------------------------------------------------------- /generators/app/index.coffee: -------------------------------------------------------------------------------- 1 | _s = require 'underscore.string' 2 | path = require 'path' 3 | chalk = require 'chalk' 4 | yosay = require 'yosay' 5 | generators = require 'yeoman-generator' 6 | 7 | module.exports = generators.Base.extend 8 | 9 | initializing : -> 10 | 11 | @log yosay( 12 | "Welcome to the amazing #{chalk.green('Phaser-Coffeescript-Gulp')} generator!" 13 | ) 14 | 15 | 16 | install : -> 17 | 18 | @installDependencies() 19 | 20 | 21 | prompting : -> 22 | 23 | done = @async() 24 | 25 | @prompt [ 26 | { 27 | type: 'input' 28 | name: 'appName' 29 | message: 'Enter your app name' 30 | default : this.appname 31 | } 32 | { 33 | type: 'input' 34 | name: 'phaserVersion' 35 | message: 'Which Phaser version do you want to use?' 36 | default : '^2.8.0' 37 | } 38 | { 39 | type: 'input' 40 | name: 'appWidth' 41 | message: 'Enter desired canvas width' 42 | default : 640 43 | } 44 | { 45 | type: 'input' 46 | name: 'appHeight' 47 | message: 'Enter desired canvas height' 48 | default : 480 49 | } 50 | { 51 | type: 'confirm' 52 | name: 'centerApp' 53 | message: 'Would you like canvas to be centered?' 54 | default : false 55 | } 56 | ], (props) => 57 | props.appName = _s.slugify props.appName 58 | @props = props 59 | done() 60 | 61 | 62 | configuring : -> 63 | 64 | 65 | default : -> 66 | 67 | 68 | writing : 69 | 70 | app : -> 71 | @fs.copyTpl( 72 | @templatePath('_index.html'), @destinationPath('app/index.html'), 73 | { appName : @props.appName } 74 | ) 75 | 76 | @fs.copyTpl( 77 | @templatePath('styles/style.css'), @destinationPath('app/styles/style.css'), 78 | { centerApp : @props.centerApp, appWidth : @props.appWidth, appHeight : @props.appHeight } 79 | ) 80 | 81 | @fs.copy @templatePath('assets/**'), @destinationPath('app/assets') 82 | @fs.copy @templatePath('scripts/states/boot.coffee'), @destinationPath('app/scripts/states/boot.coffee') 83 | @fs.copy @templatePath('scripts/states/menu.coffee'), @destinationPath('app/scripts/states/menu.coffee') 84 | @fs.copy @templatePath('scripts/states/main.coffee'), @destinationPath('app/scripts/states/main.coffee') 85 | @fs.copy @templatePath('scripts/states/preload.coffee'), @destinationPath('app/scripts/states/preload.coffee') 86 | 87 | @fs.copyTpl( 88 | @templatePath('scripts/game.coffee'), @destinationPath('app/scripts/game.coffee'), 89 | { width : @props.appWidth, height : @props.appHeight } 90 | ) 91 | 92 | 93 | npm : -> 94 | 95 | @fs.copyTpl( 96 | @templatePath('_package.json'), @destinationPath('package.json'), 97 | { appName : @props.appName, phaserVersion: @props.phaserVersion } 98 | ) 99 | 100 | 101 | gulpFile : -> 102 | 103 | @fs.copy @templatePath('_gulpfile.coffee'), @destinationPath('gulpfile.coffee') 104 | 105 | 106 | end : -> 107 | 108 | @log chalk.green('Yeoman has completed his mission successfully!') 109 | @log chalk.gray('Install gulp `npm i gulp -g` if needed and run `gulp` to start developing some awesome games!') 110 | -------------------------------------------------------------------------------- /generators/app/index.js: -------------------------------------------------------------------------------- 1 | require('coffee-script/register'); 2 | module.exports = require('./index.coffee'); 3 | 4 | 5 | -------------------------------------------------------------------------------- /generators/app/templates/_gulpfile.coffee: -------------------------------------------------------------------------------- 1 | del = require 'del' 2 | gulp = require 'gulp' 3 | source = require 'vinyl-source-stream' 4 | buffer = require 'vinyl-buffer' 5 | plugins = require('gulp-load-plugins')() 6 | browserify = require 'browserify' 7 | browserSync = require 'browser-sync' 8 | 9 | 10 | paths = 11 | appDir : 'app' 12 | appLib : 'app/lib' 13 | appStyles : 'app/styles' 14 | appAssets : 'app/assets' 15 | appScripts : 'app/scripts' 16 | appPrefabDir : 'app/prefab' 17 | 18 | buildDir : 'build' 19 | buildLib : 'build/lib' 20 | buildStyles : 'build/styles' 21 | buildAssets : 'build/assets' 22 | buildScripts : 'build/scripts' 23 | 24 | 25 | gulp.task 'clean', (cb) -> 26 | 27 | del [paths.buildDir], cb 28 | 29 | 30 | 31 | gulp.task 'watchChanges', -> 32 | 33 | bs = browserSync.create() 34 | 35 | deleteFileFromBuildDir = (event, path) -> 36 | return unless event is 'unlink' or event is 'unlinkDir' 37 | # replacing app folder with build 38 | path = path.replace 'app/', 'build/' 39 | # deleting the file from build directory 40 | del [path], -> 41 | 42 | 43 | watchFiles = (path, gulpTask) -> 44 | 45 | bs.watch path, (event, file) -> 46 | gulp.start gulpTask 47 | deleteFileFromBuildDir event, file 48 | 49 | watchFiles "#{paths.appAssets}/**", 'copyAssets' 50 | watchFiles "#{paths.appStyles}/**", 'copyStyles' 51 | watchFiles "#{paths.appDir}/**/*.html", 'copyHtml' 52 | watchFiles "#{paths.appScripts}/**/*.coffee", 'coffeeify' 53 | watchFiles "#{paths.appPrefabDir}/**/*.coffee", 'coffeeify' 54 | 55 | 56 | gulp.task 'copyHtml', -> 57 | 58 | gulp 59 | .src "#{paths.appDir}/*.html" 60 | .pipe gulp.dest paths.buildDir 61 | 62 | 63 | gulp.task 'copyAssets', -> 64 | 65 | gulp 66 | .src "#{paths.appAssets}/**/*" 67 | .pipe gulp.dest paths.buildAssets 68 | 69 | 70 | gulp.task 'copyStyles', -> 71 | 72 | gulp 73 | .src "#{paths.appStyles}/**/*" 74 | .pipe gulp.dest paths.buildStyles 75 | 76 | 77 | gulp.task 'coffeeify', -> 78 | 79 | b = browserify 80 | entries : "#{paths.appScripts}/game.coffee" 81 | debug : on 82 | transform : ['coffeeify'] 83 | extensions : ['.coffee'] 84 | 85 | b.bundle() 86 | .pipe source "#{paths.appScripts}/game.coffee" 87 | .pipe buffer() 88 | .pipe plugins.rename 'game.js' 89 | .pipe gulp.dest "#{paths.buildDir}/scripts" 90 | 91 | 92 | gulp.task 'browserSync', ['build'], -> 93 | 94 | browserSync.init ["#{paths.buildDir}/**"], 95 | server : 96 | baseDir: paths.buildDir 97 | 98 | 99 | gulp.task 'build', ['coffeeify', 'copyHtml', 'copyStyles', 'copyAssets', 'watchChanges'], -> 100 | 101 | gulp 102 | .src "#{paths.buildDir}/**/*" 103 | .pipe plugins.size 104 | title : 'build' 105 | gzip : off 106 | .pipe plugins.size 107 | title : 'build' 108 | gzip : on 109 | 110 | 111 | gulp.task 'default', ['clean'], -> 112 | 113 | gulp.start 'browserSync' 114 | 115 | -------------------------------------------------------------------------------- /generators/app/templates/_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%= appName %> 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /generators/app/templates/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%= appName %>", 3 | "version": "0.0.0", 4 | "description": "", 5 | "repository": "", 6 | "license": "", 7 | "readme": "", 8 | "browserify": { 9 | "transform": [ 10 | "browserify-shim" 11 | ] 12 | }, 13 | "browser": { 14 | "phaser": "./node_modules/phaser-ce/build/phaser.min.js" 15 | }, 16 | "browserify-shim": { 17 | "phaser": "Phaser" 18 | }, 19 | "dependencies": { 20 | }, 21 | "devDependencies": { 22 | "phaser-ce": "<%= phaserVersion %>", 23 | "chalk": "1.0.0", 24 | "coffee-script": "^1.9.3", 25 | "gulp": "^3.9.0", 26 | "browser-sync": "^2.7.12", 27 | "browserify": "^10.2.4", 28 | "browserify-shim": "^3.8.8", 29 | "coffeeify": "^1.1.0", 30 | "del": "^1.2.0", 31 | "gulp-size": "^1.2.1", 32 | "gulp-load-plugins": "0.10.0", 33 | "gulp-rename": "^1.2.2", 34 | "mocha": "*", 35 | "vinyl-buffer": "^1.0.0", 36 | "vinyl-source-stream": "^1.1.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /generators/app/templates/assets/backgrounds/starfield.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ozankasikci/generator-phaser-coffeescript-gulp/82b901df79eeb0c9302175569aa8c36d02f3eae0/generators/app/templates/assets/backgrounds/starfield.jpg -------------------------------------------------------------------------------- /generators/app/templates/assets/images/preloader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ozankasikci/generator-phaser-coffeescript-gulp/82b901df79eeb0c9302175569aa8c36d02f3eae0/generators/app/templates/assets/images/preloader.gif -------------------------------------------------------------------------------- /generators/app/templates/assets/sprites/phaser2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ozankasikci/generator-phaser-coffeescript-gulp/82b901df79eeb0c9302175569aa8c36d02f3eae0/generators/app/templates/assets/sprites/phaser2.png -------------------------------------------------------------------------------- /generators/app/templates/editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /generators/app/templates/scripts/game.coffee: -------------------------------------------------------------------------------- 1 | Phaser = require 'phaser' 2 | Boot = require './states/boot' 3 | Preload = require './states/preload' 4 | Menu = require './states/menu' 5 | Main = require './states/main' 6 | 7 | class Game extends Phaser.Game 8 | 9 | constructor : -> 10 | 11 | super <%= width %>, <%= height %>, Phaser.AUTO, 'game-content' 12 | 13 | @state.add 'boot', Boot 14 | @state.add 'preload', Preload 15 | @state.add 'menu', Menu 16 | @state.add 'main', Main 17 | 18 | @state.start 'boot' 19 | 20 | 21 | window.onload = -> 22 | 23 | game = new Game() 24 | -------------------------------------------------------------------------------- /generators/app/templates/scripts/states/boot.coffee: -------------------------------------------------------------------------------- 1 | class Boot 2 | 3 | preload: -> 4 | 5 | @game.load.image 'preloader', 'assets/images/preloader.gif' 6 | 7 | 8 | create: -> 9 | 10 | @game.stage.backgroundColor = 0x000000 11 | @scale.scaleMode = Phaser.ScaleManager.SHOW_ALL 12 | @game.state.start 'preload' 13 | 14 | 15 | module.exports = Boot 16 | -------------------------------------------------------------------------------- /generators/app/templates/scripts/states/main.coffee: -------------------------------------------------------------------------------- 1 | class Main 2 | 3 | create : -> 4 | 5 | style = { font: '35px Arial', fill: '#ff0044', align: 'center' } 6 | logo = @game.add.tileSprite 0, 0, 800, 600, 'logo' 7 | logo.alpha = 0.1 8 | text = @game.add.text @game.world.centerX, @game.world.centerY, "Ready to rock!", style 9 | text.anchor.set 0.5 10 | text.alpha = 0.1 11 | @game.add.tween(text).to( { alpha: 1 }, 5000, "Linear", true ) 12 | 13 | 14 | module.exports = Main 15 | -------------------------------------------------------------------------------- /generators/app/templates/scripts/states/menu.coffee: -------------------------------------------------------------------------------- 1 | class Menu 2 | 3 | create : -> 4 | 5 | @backgroundColor = 0xFFFFFF 6 | @game.state.start 'main' 7 | 8 | 9 | module.exports = Menu 10 | -------------------------------------------------------------------------------- /generators/app/templates/scripts/states/preload.coffee: -------------------------------------------------------------------------------- 1 | class Preload 2 | 3 | preload: -> 4 | 5 | loadingBar = @add.sprite 320, 240, 'preloader' 6 | loadingBar.anchor.setTo 0.5, 0.5 7 | @load.setPreloadSprite loadingBar 8 | 9 | @game.load.image 'starBackground','assets/backgrounds/starfield.jpg', 138, 15 10 | @game.load.image 'logo', 'assets/sprites/phaser2.png' 11 | 12 | 13 | create: -> 14 | 15 | @game.state.start 'menu' 16 | 17 | 18 | module.exports = Preload 19 | -------------------------------------------------------------------------------- /generators/app/templates/styles/style.css: -------------------------------------------------------------------------------- 1 | * { 2 | -webkit-user-select: none; 3 | user-select: none; 4 | } 5 | 6 | html, body { 7 | margin: 0; 8 | padding: 0; 9 | width: 100%; 10 | height: 100%; 11 | overflow: hidden; 12 | } 13 | 14 | #game-content { 15 | <% if(centerApp){ %> 16 | margin: 20px auto; 17 | <% } %> 18 | width: <%= appWidth %>px; 19 | height: <%= appHeight %>px; 20 | } 21 | -------------------------------------------------------------------------------- /generators/prefab/index.coffee: -------------------------------------------------------------------------------- 1 | _s = require 'underscore.string' 2 | chalk = require 'chalk' 3 | yosay = require 'yosay' 4 | generators = require 'yeoman-generator' 5 | 6 | module.exports = generators.NamedBase.extend 7 | 8 | initializing : -> 9 | 10 | @log yosay chalk.green "Creating a new prefab, hang tight!" 11 | @name = @name.replace '.coffee', '' 12 | 13 | 14 | prompting : -> 15 | 16 | prefabTypesWithSpriteKey = ['Sprite', 'TileSprite', 'Emitter', 'Button'] 17 | 18 | done = @async() 19 | 20 | @prompt [ 21 | { 22 | type : 'list' 23 | name : 'prefabType' 24 | message : 'What type of prefab would you like to create?' 25 | choices : ['Text', 'Group', 'Sprite', 'Button', 'Emitter', 'TileSprite', 'BitmapData'] 26 | default : 0 27 | } 28 | { 29 | when : (props) -> props.prefabType in prefabTypesWithSpriteKey 30 | type : 'input' 31 | name : 'prefabSpriteKey' 32 | message : "What is your prefab's sprite key?" 33 | validate : (input) -> 34 | return 'You must enter a sprite key' unless input 35 | return true 36 | } 37 | ], (props) => 38 | @props = props 39 | @props.prefabClassName = _s.classify @name 40 | @props.prefabSpriteKey = _s.slugify props.prefabSpriteKey 41 | done() 42 | 43 | 44 | writing : 45 | 46 | app : -> 47 | 48 | templates = 49 | 'Text' : '_prefabText.coffee' 50 | 'Group' : '_prefabGroup.coffee' 51 | 'Button' : '_prefabButton.coffee' 52 | 'Sprite' : '_prefabSprite.coffee' 53 | 'Emitter' : '_prefabEmitter.coffee' 54 | 'TileSprite' : '_prefabTileSprite.coffee' 55 | 'BitmapData' : '_prefabBitmapData.coffee' 56 | 57 | @fs.copyTpl( 58 | @templatePath(templates[@props.prefabType]), @destinationPath("app/scripts/prefabs/#{@name}.coffee"), 59 | { prefabSpriteKey : @props.prefabSpriteKey, prefabClassName : @props.prefabClassName } 60 | ) 61 | 62 | 63 | end : -> 64 | 65 | @log chalk.yellow("File name is: #{@name}.coffee") 66 | @log chalk.yellow("Class name is: #{@props.prefabClassName}") 67 | @log chalk.green("Created a new #{@props.prefabType} prefab successfully!") 68 | 69 | 70 | -------------------------------------------------------------------------------- /generators/prefab/index.js: -------------------------------------------------------------------------------- 1 | require('coffee-script/register'); 2 | module.exports = require('./index.coffee'); 3 | 4 | 5 | -------------------------------------------------------------------------------- /generators/prefab/templates/_prefabBitmapData.coffee: -------------------------------------------------------------------------------- 1 | module.exports = class <%= prefabClassName %> extends Phaser.BitmapData 2 | 3 | constructor : (game, width, height, key = '') -> 4 | 5 | key = game.rnd.uuid() unless key 6 | super game, key, width, height 7 | 8 | -------------------------------------------------------------------------------- /generators/prefab/templates/_prefabButton.coffee: -------------------------------------------------------------------------------- 1 | module.exports = class <%= prefabClassName %> extends Phaser.Button 2 | 3 | constructor : (game, x, y) -> 4 | 5 | super game, x, y, '<%= prefabSpriteKey %>', @actionOnClick 6 | 7 | 8 | update : -> 9 | 10 | 11 | actionOnClick : -> 12 | -------------------------------------------------------------------------------- /generators/prefab/templates/_prefabEmitter.coffee: -------------------------------------------------------------------------------- 1 | module.exports = class <%= prefabClassName %> extends Phaser.Particles.Arcade.Emitter 2 | 3 | constructor : (game, x, y, maxParticles = 50) -> 4 | 5 | super game, x, y, maxParticles 6 | @makeParticles '<%= prefabSpriteKey %>' 7 | 8 | 9 | update : -> 10 | -------------------------------------------------------------------------------- /generators/prefab/templates/_prefabGroup.coffee: -------------------------------------------------------------------------------- 1 | module.exports = class <%= prefabClassName %> extends Phaser.Group 2 | 3 | constructor : (game) -> 4 | 5 | super game 6 | 7 | -------------------------------------------------------------------------------- /generators/prefab/templates/_prefabSprite.coffee: -------------------------------------------------------------------------------- 1 | module.exports = class <%= prefabClassName %> extends Phaser.Sprite 2 | 3 | constructor : (game, x, y, frame = null) -> 4 | 5 | super game, x, y, '<%= prefabSpriteKey %>', frame 6 | @game.add.existing this 7 | 8 | 9 | update : -> 10 | -------------------------------------------------------------------------------- /generators/prefab/templates/_prefabText.coffee: -------------------------------------------------------------------------------- 1 | module.exports = class <%= prefabClassName %> extends Phaser.Text 2 | 3 | constructor : (game, x, y, text, style = {}) -> 4 | 5 | super game, x, y, text, style 6 | @game.add.existing this 7 | 8 | -------------------------------------------------------------------------------- /generators/prefab/templates/_prefabTileSprite.coffee: -------------------------------------------------------------------------------- 1 | module.exports = class <%= prefabClassName %> extends Phaser.TileSprite 2 | 3 | constructor : (game, x, y, width, height, frame = null) -> 4 | 5 | super game, x, y, width, height, '<%= prefabSpriteKey %>', frame 6 | @game.add.existing this 7 | 8 | 9 | update : -> 10 | -------------------------------------------------------------------------------- /generators/state/index.coffee: -------------------------------------------------------------------------------- 1 | _s = require 'underscore.string' 2 | chalk = require 'chalk' 3 | yosay = require 'yosay' 4 | generators = require 'yeoman-generator' 5 | 6 | module.exports = generators.NamedBase.extend 7 | 8 | initializing : -> 9 | 10 | @log yosay chalk.green "Creating a new state, hang tight!" 11 | @name = @name.replace '.coffee', '' 12 | @stateClassName = _s.classify @name 13 | 14 | 15 | prompting : -> 16 | 17 | 18 | writing : 19 | 20 | app : -> 21 | 22 | @fs.copyTpl( 23 | @templatePath('_state.coffee'), @destinationPath("app/scripts/states/#{@name}.coffee"), 24 | { stateClassName : @stateClassName } 25 | ) 26 | 27 | 28 | end : -> 29 | 30 | @log chalk.yellow("File name is: #{@name}.coffee") 31 | @log chalk.yellow("Class name is: #{@stateClassName}") 32 | @log chalk.green('Created a new state successfully!') 33 | 34 | 35 | -------------------------------------------------------------------------------- /generators/state/index.js: -------------------------------------------------------------------------------- 1 | require('coffee-script/register'); 2 | module.exports = require('./index.coffee'); 3 | 4 | 5 | -------------------------------------------------------------------------------- /generators/state/templates/_state.coffee: -------------------------------------------------------------------------------- 1 | class <%= stateClassName %> 2 | 3 | preload : -> 4 | 5 | 6 | create : -> 7 | 8 | 9 | update : -> 10 | 11 | 12 | render : -> 13 | 14 | 15 | module.exports = <%= stateClassName %> 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-phaser-coffeescript-gulp", 3 | "version": "0.5.0", 4 | "description": "A yeoman generator for developing games with Phaser framework using coffeescript and gulp. Browserifies, coffeeifies and live reloads using browser-sync.", 5 | "license": "MIT", 6 | "main": "app/index.js", 7 | "repository": "ozankasikci/generator-phaser-coffeescript-gulp", 8 | "author": { 9 | "name": "Ozan Kaşıkçı", 10 | "email": "kasikciozan@yandex.com", 11 | "url": "https://github.com/ozankasikci" 12 | }, 13 | "scripts": { 14 | "test": "mocha" 15 | }, 16 | "files": [ 17 | "generators" 18 | ], 19 | "keywords": [ 20 | "yeoman-generator", 21 | "phaser", 22 | "HTML5", 23 | "game", 24 | "coffee-script" 25 | ], 26 | "dependencies": { 27 | "chalk": "^1.0.0", 28 | "coffee-script": "^1.9.3", 29 | "gulp": "^3.9.0", 30 | "underscore.string": "^3.1.1", 31 | "yeoman-generator": "^0.20.1", 32 | "yosay": "^1.0.2" 33 | }, 34 | "devDependencies": { 35 | "mocha": "*" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/test-app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | var assert = require('yeoman-generator').assert; 5 | var helpers = require('yeoman-generator').test; 6 | var os = require('os'); 7 | 8 | describe('phaser-coffeescript:app', function () { 9 | before(function (done) { 10 | helpers.run(path.join(__dirname, '../generators/app')) 11 | .withOptions({ skipInstall: true }) 12 | .withPrompts({ someOption: true }) 13 | .on('end', done); 14 | }); 15 | 16 | it('creates files', function () { 17 | assert.file([ 18 | 'bower.json', 19 | 'package.json', 20 | '.editorconfig', 21 | '.jshintrc' 22 | ]); 23 | }); 24 | }); 25 | --------------------------------------------------------------------------------