diff --git a/harkka3/samson/main.js b/harkka3/samson/main.js index 8e8fc598066faa93c5fcf2bf9bc41fd7281197c0..74ccd38c00cc13006b4e47a64151731c182d43c8 100644 --- a/harkka3/samson/main.js +++ b/harkka3/samson/main.js @@ -9,4 +9,4 @@ game.state.add('state6', demo.state6); game.state.add('state7', demo.state7); game.state.add('state8', demo.state8); game.state.add('state9', demo.state9); -game.state.start('start1'); \ No newline at end of file +game.state.start('state0'); \ No newline at end of file diff --git a/harkka3/samson/state0.js b/harkka3/samson/state0.js index 2ab49daf5e333dc0cebaba764638211dfe24e515..5099ec248b0dfdd8ecb2e59ff073d5b66cb67097 100644 --- a/harkka3/samson/state0.js +++ b/harkka3/samson/state0.js @@ -5,6 +5,28 @@ demo.state0.prototype = { create: function(){ game.stage.backgroundColor = '#ffcccc'; console.log('state0'); + addChangeStateEventListeners(); }, update: function(){} +} + +function changeState(i, stateNum){ + game.state.start('state' + stateNum); +} + +function addKeyCallback(key, fn, args){ + game.input.keyboard.addKey(key).onDown.add(fn, null, null, args); +} + +function addChangeStateEventListeners(){ + addKeyCallback(Phaser.Keyboard.ZERO, changeState, 0); + addKeyCallback(Phaser.Keyboard.ONE, changeState, 1); + addKeyCallback(Phaser.Keyboard.TWO, changeState, 2); + addKeyCallback(Phaser.Keyboard.THREE, changeState, 3); + addKeyCallback(Phaser.Keyboard.FOUR, changeState, 4); + addKeyCallback(Phaser.Keyboard.FIVE, changeState, 5); + addKeyCallback(Phaser.Keyboard.SIX, changeState, 6); + addKeyCallback(Phaser.Keyboard.SEVEN, changeState, 7); + addKeyCallback(Phaser.Keyboard.EIGHT, changeState, 8); + addKeyCallback(Phaser.Keyboard.NINE, changeState, 9); } \ No newline at end of file diff --git a/harkka3/samson/state1.js b/harkka3/samson/state1.js index dfa24cff592f29112112006154cde2941857d8ab..bddb4666f2c5ccbc43b21d38678c976ef5886472 100644 --- a/harkka3/samson/state1.js +++ b/harkka3/samson/state1.js @@ -4,6 +4,7 @@ demo.state1.prototype = { create: function(){ game.stage.backgroundColor = '#DDDDDD'; console.log('state1'); + addChangeStateEventListeners(); }, update: function(){} } \ No newline at end of file diff --git a/harkka3/samson/state2.js b/harkka3/samson/state2.js index 3d106ffcd66c409835534aa60874d30cba63f8b8..49c24f4f75e3a6db6cd9fa8f762f91bf2a24990b 100644 --- a/harkka3/samson/state2.js +++ b/harkka3/samson/state2.js @@ -2,8 +2,9 @@ demo.state2 = function(){}; demo.state2.prototype = { preload: function(){}, create: function(){ - game.stage.backgroundColor = '#ffcccc'; + game.stage.backgroundColor = '#0066ff'; console.log('state2'); + addChangeStateEventListeners(); }, update: function(){} } \ No newline at end of file diff --git a/harkka3/samson/state3.js b/harkka3/samson/state3.js index e25b3375acabf4d54a9a546a53014bf7f38b1040..fd3e9611a2514a343ac197e54e3fde79c529a76a 100644 --- a/harkka3/samson/state3.js +++ b/harkka3/samson/state3.js @@ -2,8 +2,9 @@ demo.state3 = function(){}; demo.state3.prototype = { preload: function(){}, create: function(){ - game.stage.backgroundColor = '#ffcccc'; + game.stage.backgroundColor = '#cc3300'; console.log('state3'); + addChangeStateEventListeners(); }, update: function(){} } \ No newline at end of file diff --git a/harkka3/samson/state4.js b/harkka3/samson/state4.js index ed7d555d8b06f3d1d79bdfbd860fe73bacc6e656..7409a84338fbc3354b4bded2c3983a76b025e4c5 100644 --- a/harkka3/samson/state4.js +++ b/harkka3/samson/state4.js @@ -2,8 +2,9 @@ demo.state4 = function(){}; demo.state4.prototype = { preload: function(){}, create: function(){ - game.stage.backgroundColor = '#ffcccc'; + game.stage.backgroundColor = '#ffff00'; console.log('state4'); + addChangeStateEventListeners(); }, update: function(){} } \ No newline at end of file diff --git a/harkka3/samson/state5.js b/harkka3/samson/state5.js index 5f5292a6978a8a69ddf9352ae7592b891a7f0bf1..8b20925b86fc76881c7a2bf11d1318427bbae9f9 100644 --- a/harkka3/samson/state5.js +++ b/harkka3/samson/state5.js @@ -2,8 +2,9 @@ demo.state5 = function(){}; demo.state5.prototype = { preload: function(){}, create: function(){ - game.stage.backgroundColor = '#ffcccc'; + game.stage.backgroundColor = '#009900'; console.log('state5'); + addChangeStateEventListeners(); }, update: function(){} } \ No newline at end of file diff --git a/harkka3/samson/state6.js b/harkka3/samson/state6.js index b25736b888bc3de3def38f3b7bdb8717508973b7..b4b25e7d701db06131492716c3226a190c7098e4 100644 --- a/harkka3/samson/state6.js +++ b/harkka3/samson/state6.js @@ -2,8 +2,9 @@ demo.state6 = function(){}; demo.state6.prototype = { preload: function(){}, create: function(){ - game.stage.backgroundColor = '#ffcccc'; + game.stage.backgroundColor = '#000099'; console.log('state6'); + addChangeStateEventListeners(); }, update: function(){} } \ No newline at end of file diff --git a/harkka3/samson/state7.js b/harkka3/samson/state7.js index cc1004e7343b27eef6142d5b81316b697aa9c9da..3e0eecc904d6df23dc78a120ee7335c17d9a606f 100644 --- a/harkka3/samson/state7.js +++ b/harkka3/samson/state7.js @@ -2,8 +2,9 @@ demo.state7 = function(){}; demo.state7.prototype = { preload: function(){}, create: function(){ - game.stage.backgroundColor = '#ffcccc'; + game.stage.backgroundColor = '#ff00ff'; console.log('state7'); + addChangeStateEventListeners(); }, update: function(){} } \ No newline at end of file diff --git a/harkka3/samson/state8.js b/harkka3/samson/state8.js index 43ba98ad7c061513abbca39d194255e41067da4e..073d44a1c1c6774cd401377aee2dd87c1b7c7f6c 100644 --- a/harkka3/samson/state8.js +++ b/harkka3/samson/state8.js @@ -2,8 +2,9 @@ demo.state8 = function(){}; demo.state8.prototype = { preload: function(){}, create: function(){ - game.stage.backgroundColor = '#ffcccc'; + game.stage.backgroundColor = '#000066'; console.log('state8'); + addChangeStateEventListeners(); }, update: function(){} } \ No newline at end of file diff --git a/harkka3/samson/state9.js b/harkka3/samson/state9.js index 44ccca660ea87a00dba728b175c9799c9c7e28a8..f9a0737b3de5a5cf0cec7aba1e0f1e136cb29231 100644 --- a/harkka3/samson/state9.js +++ b/harkka3/samson/state9.js @@ -2,8 +2,9 @@ demo.state9 = function(){}; demo.state9.prototype = { preload: function(){}, create: function(){ - game.stage.backgroundColor = '#ffcccc'; + game.stage.backgroundColor = '#000000'; console.log('state9'); + addChangeStateEventListeners(); }, update: function(){} } \ No newline at end of file