Skip to content

Commit 06c6995

Browse files
committed
New Phaser Project Template specifically for requireJS in the resources/Project Templates folder (many thanks @ashatch)
1 parent 937085a commit 06c6995

8 files changed

Lines changed: 106 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Version 2.0.4 - "Mos Shirare" - in development
136136
* Timer.timeCap is a new setting allowing your Timers to protect against unexpectedly large delta timers (such as raf de-vis or CPU grind).
137137
* Camera.unfollow allows you to easily unfollow a tracked object (thanks @alvinsight, #755)
138138
* Animation.setFrame allows you to set the animation to a specific frame (thanks @adamholdenyall, #706)
139+
* New Phaser Project Template specifically for requireJS in the `resources/Project Templates` folder (many thanks @ashatch)
139140

140141

141142
### Bug Fixes
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "src/libs"
3+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
# Phaser-RequireJS
3+
4+
Boilerplate project that combines [Phaser](http://phaser.io) with [RequireJS](http://requirejs.org).
5+
6+
## Structure
7+
8+
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`.
9+
10+
## NOTE
11+
12+
I haven't yet fully decided whether RequireJS is the right way of modularising a Phaser game.
13+
14+
15+
## Change Log
16+
17+
### Version 0.1.0
18+
19+
- Initial project.
176 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "Phaser-RequireJS",
3+
"version": "0.1.0",
4+
"description": "Phaser Hello World with RequireJS",
5+
6+
"authors": [
7+
"ashatch <andrew@andrewhatch.net>"
8+
],
9+
10+
"license": "MIT",
11+
12+
"dependencies": {
13+
"requirejs": "latest",
14+
"phaser": "latest"
15+
},
16+
17+
"ignore": [
18+
"src/libs"
19+
]
20+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8" />
5+
<title>hello phaser-requirejs</title>
6+
<script data-main="src/main" src="src/libs/requirejs/require.js"></script>
7+
</head>
8+
<body>
9+
</body>
10+
</html>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
define([
2+
'phaser'
3+
], function (Phaser) {
4+
'use strict';
5+
6+
function Game() {
7+
console.log('Making the Game');
8+
}
9+
10+
Game.prototype = {
11+
constructor: Game,
12+
13+
start: function() {
14+
this.game = new Phaser.Game(800, 600, Phaser.AUTO, '', {
15+
preload: this.preload,
16+
create: this.create
17+
});
18+
},
19+
20+
preload: function() {
21+
this.game.load.image('logo', 'assets/phaser.png');
22+
},
23+
24+
create: function() {
25+
var logo = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, 'logo');
26+
logo.anchor.setTo(0.5, 0.5);
27+
}
28+
};
29+
30+
return Game;
31+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(function () {
2+
'use strict';
3+
4+
requirejs.config({
5+
baseUrl: "src/",
6+
7+
paths: {
8+
phaser: 'libs/phaser/phaser.min',
9+
},
10+
11+
shim: {
12+
'phaser': {
13+
exports: 'Phaser'
14+
}
15+
}
16+
});
17+
18+
require(['phaser', 'game'], function (Phaser, Game) {
19+
var game = new Game();
20+
game.start();
21+
});
22+
}());

0 commit comments

Comments
 (0)