Skip to content
Snippets Groups Projects
Commit 75ca7fa5 authored by Samson's avatar Samson
Browse files

state0-9

parent b3f76a43
No related branches found
No related tags found
No related merge requests found
Pipeline #162339 passed
...@@ -9,4 +9,4 @@ game.state.add('state6', demo.state6); ...@@ -9,4 +9,4 @@ game.state.add('state6', demo.state6);
game.state.add('state7', demo.state7); game.state.add('state7', demo.state7);
game.state.add('state8', demo.state8); game.state.add('state8', demo.state8);
game.state.add('state9', demo.state9); game.state.add('state9', demo.state9);
game.state.start('start1'); game.state.start('state0');
\ No newline at end of file \ No newline at end of file
...@@ -5,6 +5,28 @@ demo.state0.prototype = { ...@@ -5,6 +5,28 @@ demo.state0.prototype = {
create: function(){ create: function(){
game.stage.backgroundColor = '#ffcccc'; game.stage.backgroundColor = '#ffcccc';
console.log('state0'); console.log('state0');
addChangeStateEventListeners();
}, },
update: function(){} 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
...@@ -4,6 +4,7 @@ demo.state1.prototype = { ...@@ -4,6 +4,7 @@ demo.state1.prototype = {
create: function(){ create: function(){
game.stage.backgroundColor = '#DDDDDD'; game.stage.backgroundColor = '#DDDDDD';
console.log('state1'); console.log('state1');
addChangeStateEventListeners();
}, },
update: function(){} update: function(){}
} }
\ No newline at end of file
...@@ -2,8 +2,9 @@ demo.state2 = function(){}; ...@@ -2,8 +2,9 @@ demo.state2 = function(){};
demo.state2.prototype = { demo.state2.prototype = {
preload: function(){}, preload: function(){},
create: function(){ create: function(){
game.stage.backgroundColor = '#ffcccc'; game.stage.backgroundColor = '#0066ff';
console.log('state2'); console.log('state2');
addChangeStateEventListeners();
}, },
update: function(){} update: function(){}
} }
\ No newline at end of file
...@@ -2,8 +2,9 @@ demo.state3 = function(){}; ...@@ -2,8 +2,9 @@ demo.state3 = function(){};
demo.state3.prototype = { demo.state3.prototype = {
preload: function(){}, preload: function(){},
create: function(){ create: function(){
game.stage.backgroundColor = '#ffcccc'; game.stage.backgroundColor = '#cc3300';
console.log('state3'); console.log('state3');
addChangeStateEventListeners();
}, },
update: function(){} update: function(){}
} }
\ No newline at end of file
...@@ -2,8 +2,9 @@ demo.state4 = function(){}; ...@@ -2,8 +2,9 @@ demo.state4 = function(){};
demo.state4.prototype = { demo.state4.prototype = {
preload: function(){}, preload: function(){},
create: function(){ create: function(){
game.stage.backgroundColor = '#ffcccc'; game.stage.backgroundColor = '#ffff00';
console.log('state4'); console.log('state4');
addChangeStateEventListeners();
}, },
update: function(){} update: function(){}
} }
\ No newline at end of file
...@@ -2,8 +2,9 @@ demo.state5 = function(){}; ...@@ -2,8 +2,9 @@ demo.state5 = function(){};
demo.state5.prototype = { demo.state5.prototype = {
preload: function(){}, preload: function(){},
create: function(){ create: function(){
game.stage.backgroundColor = '#ffcccc'; game.stage.backgroundColor = '#009900';
console.log('state5'); console.log('state5');
addChangeStateEventListeners();
}, },
update: function(){} update: function(){}
} }
\ No newline at end of file
...@@ -2,8 +2,9 @@ demo.state6 = function(){}; ...@@ -2,8 +2,9 @@ demo.state6 = function(){};
demo.state6.prototype = { demo.state6.prototype = {
preload: function(){}, preload: function(){},
create: function(){ create: function(){
game.stage.backgroundColor = '#ffcccc'; game.stage.backgroundColor = '#000099';
console.log('state6'); console.log('state6');
addChangeStateEventListeners();
}, },
update: function(){} update: function(){}
} }
\ No newline at end of file
...@@ -2,8 +2,9 @@ demo.state7 = function(){}; ...@@ -2,8 +2,9 @@ demo.state7 = function(){};
demo.state7.prototype = { demo.state7.prototype = {
preload: function(){}, preload: function(){},
create: function(){ create: function(){
game.stage.backgroundColor = '#ffcccc'; game.stage.backgroundColor = '#ff00ff';
console.log('state7'); console.log('state7');
addChangeStateEventListeners();
}, },
update: function(){} update: function(){}
} }
\ No newline at end of file
...@@ -2,8 +2,9 @@ demo.state8 = function(){}; ...@@ -2,8 +2,9 @@ demo.state8 = function(){};
demo.state8.prototype = { demo.state8.prototype = {
preload: function(){}, preload: function(){},
create: function(){ create: function(){
game.stage.backgroundColor = '#ffcccc'; game.stage.backgroundColor = '#000066';
console.log('state8'); console.log('state8');
addChangeStateEventListeners();
}, },
update: function(){} update: function(){}
} }
\ No newline at end of file
...@@ -2,8 +2,9 @@ demo.state9 = function(){}; ...@@ -2,8 +2,9 @@ demo.state9 = function(){};
demo.state9.prototype = { demo.state9.prototype = {
preload: function(){}, preload: function(){},
create: function(){ create: function(){
game.stage.backgroundColor = '#ffcccc'; game.stage.backgroundColor = '#000000';
console.log('state9'); console.log('state9');
addChangeStateEventListeners();
}, },
update: function(){} update: function(){}
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment