Skip to content

Commit

Permalink
ajout page crédits
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco59 committed Sep 6, 2015
1 parent b3b6660 commit b3fe161
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
});

require(['phaser', 'scenes/game', 'scenes/boot', 'scenes/preloader', 'scenes/menu'], function (Phaser, Game, Boot, Preloader, Menu) {
require(['phaser', 'scenes/game', 'scenes/boot', 'scenes/preloader', 'scenes/menu', 'scenes/credit'], function (Phaser, Game, Boot, Preloader, Menu, Credit) {
var SAFE_ZONE_WIDTH = 640;
var SAFE_ZONE_HEIGHT = 1136;
var game = new Phaser.Game( SAFE_ZONE_WIDTH/2, SAFE_ZONE_HEIGHT/2, Phaser.AUTO, 'game_div');
Expand All @@ -25,6 +25,7 @@
game.state.add('Boot', Boot, true);
game.state.add('Preloader', Preloader, false);
game.state.add('Menu', Menu, false);
game.state.add('Credit', Credit, false);
game.state.add('Game', Game, false);

});
Expand Down
44 changes: 44 additions & 0 deletions src/scenes/credit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
define([
'phaser','sprites/window'
], function (Phaser, Window) {
'use strict';

function Credit(game) {
this.music = null;
this.clic = null;
this.playButton = null;
}

Credit.prototype = {
constructor: Credit,
create: function () {
// We've already preloaded our assets, so let's kick right into the Main Menu itself.
// background
var imgCredits = this.game.add.sprite(0, 0, 'credits-img', this.startGame);
imgCredits.scale.setTo(0.5, 0.5);

this.music = this.game.add.audio('zik-intro');
this.music.loop=true;
this.music.play();
this.music.volume=0.25;

this.clic = this.game.add.audio('clic');

},
update: function () {
// à virer quand on voudra vraiment le menu du cul
// this.state.start('Game');
},
startGame: function (pointer) {
// Ok, the Play Button has been clicked or touched, so let's stop the music (otherwise it'll carry on playing)
this.music.stop();
this.clic.play();

// And start the actual game
this.state.start('Game');

}
};

return Credit;
});
13 changes: 13 additions & 0 deletions src/scenes/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ define([
//this.playButton = this.add.button(400, 600, 'logo', this.startGame, this);
this.playButton = this.add.button(114, 416, 'play-spritesheet', this.startGame, this, 0, 0, 1);
this.playButton.scale.setTo(0.5, 0.5);

// Ajout texte credits
this.creditText = this.add.button(10, 10, 'credits-txt', this.startCredit, this, 0, 0, 1);
this.creditText.scale.setTo(0.5, 0.5);

},
update: function () {
Expand All @@ -92,6 +96,15 @@ define([
// And start the actual game
this.state.start('Game');

},
startCredit: function () {
// Ok, the Play Button has been clicked or touched, so let's stop the music (otherwise it'll carry on playing)
this.music.stop();
this.clic.play();

// And start the actual game
this.state.start('Credit');

}
};

Expand Down
2 changes: 2 additions & 0 deletions src/scenes/preloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ define([
['nuage2', 'assets/images/nuage2.png'],
['logo-bandeau', 'assets/images/logo-bandeau.png'],
['filter-alpha', 'assets/images/filter-alpha.png'],
['credits-img', 'assets/images/credits.png'],
['credits-txt', 'assets/images/credits-txt.png']
];

this.sprites = [
Expand Down

0 comments on commit b3fe161

Please sign in to comment.