1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
   |  
var game = new Phaser.Game(500, 350, Phaser.AUTO, 'gameContainer', {preload: preload, create: create, update: update});
var tab = new Array();
tab = [
	["un", "deux", "trois", "quatre"],
	["un", "deux", "trois", "quatre", "cinq"],
	["un", "deux", "trois"]
];
var choix;
var style = { font: "40px Arial", fill: "#FF0000", align: "center" };
 
 
var motAleatoire = Math.floor((Math.random() * tab.length));
 
var placeX;
 
 
function preload() {
	game.stage.backgroundColor = 0xffffff;
}
 
 
function create() {
 
		function selectionTab(){
 
 
			console.log(motAleatoire);
			choix = tab[motAleatoire];
 
			for(var i = 0, length1 = choix.length; i < length1; i++){
				placeX = (300 / choix.length) * i;
				affiche(choix[i], placeX);
			}		
	}
	selectionTab();
 
	function affiche(m, x){
		console.log(m);
		var text = game.add.text(x, game.world.centerY, m, style);
		text.inputEnabled = true;
		text.events.onInputDown.add(over, this, m)
	}
 
 
}
 
 
function over(m){
	console.log(m);
} |