Skip to content

Commit

Permalink
New Phaser Project Template specifically for requireJS in the `resour…
Browse files Browse the repository at this point in the history
…ces/Project Templates` folder (many thanks @ashatch)
  • Loading branch information
photonstorm committed Apr 29, 2014
1 parent 937085a commit 06c6995
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Version 2.0.4 - "Mos Shirare" - in development
* Timer.timeCap is a new setting allowing your Timers to protect against unexpectedly large delta timers (such as raf de-vis or CPU grind).
* Camera.unfollow allows you to easily unfollow a tracked object (thanks @alvinsight, #755)
* Animation.setFrame allows you to set the animation to a specific frame (thanks @adamholdenyall, #706)
* New Phaser Project Template specifically for requireJS in the `resources/Project Templates` folder (many thanks @ashatch)


### Bug Fixes
Expand Down
3 changes: 3 additions & 0 deletions resources/Project Templates/RequireJS/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "src/libs"
}
19 changes: 19 additions & 0 deletions resources/Project Templates/RequireJS/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

# Phaser-RequireJS

Boilerplate project that combines [Phaser](http://phaser.io) with [RequireJS](http://requirejs.org).

## Structure

The *Hello World* game is found in `www`. The `www` directory will need a `bower install`. Bower dependencies are configured to install into `www/src/libs`.

## NOTE

I haven't yet fully decided whether RequireJS is the right way of modularising a Phaser game.


## Change Log

### Version 0.1.0

- Initial project.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions resources/Project Templates/RequireJS/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Phaser-RequireJS",
"version": "0.1.0",
"description": "Phaser Hello World with RequireJS",

"authors": [
"ashatch <[email protected]>"
],

"license": "MIT",

"dependencies": {
"requirejs": "latest",
"phaser": "latest"
},

"ignore": [
"src/libs"
]
}
10 changes: 10 additions & 0 deletions resources/Project Templates/RequireJS/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>hello phaser-requirejs</title>
<script data-main="src/main" src="src/libs/requirejs/require.js"></script>
</head>
<body>
</body>
</html>
31 changes: 31 additions & 0 deletions resources/Project Templates/RequireJS/src/game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
define([
'phaser'
], function (Phaser) {
'use strict';

function Game() {
console.log('Making the Game');
}

Game.prototype = {
constructor: Game,

start: function() {
this.game = new Phaser.Game(800, 600, Phaser.AUTO, '', {
preload: this.preload,
create: this.create
});
},

preload: function() {
this.game.load.image('logo', 'assets/phaser.png');
},

create: function() {
var logo = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, 'logo');
logo.anchor.setTo(0.5, 0.5);
}
};

return Game;
});
22 changes: 22 additions & 0 deletions resources/Project Templates/RequireJS/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(function () {
'use strict';

requirejs.config({
baseUrl: "src/",

paths: {
phaser: 'libs/phaser/phaser.min',
},

shim: {
'phaser': {
exports: 'Phaser'
}
}
});

require(['phaser', 'game'], function (Phaser, Game) {
var game = new Game();
game.start();
});
}());

0 comments on commit 06c6995

Please sign in to comment.