add back button

This commit is contained in:
Juraj Michalek
2015-12-30 15:59:34 +01:00
parent a34e278372
commit b0604f9305
2 changed files with 13 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 KiB

After

Width:  |  Height:  |  Size: 164 KiB

View File

@@ -49,6 +49,11 @@ state.create = function() {
// Sky layer
this.addChild(this.tilemap.layers[2]);
this.backButton = new Kiwi.GameObjects.Sprite(this, this.textures.base, 0, 0);
this.backButton.cellIndex = 24;
this.backButton.input.onUp.add(this.backButtonReleased, this);
this.addChild(this.backButton);
// Create collision layer
for(var i = 21; i < this.tilemap.tileTypes.length; i++) {
@@ -67,6 +72,14 @@ state.create = function() {
this.character.input.onUp.add( this.buttonReleased, this );
}
state.backButtonReleased = function(sprite, mouse) {
if ((mouse.x > 48) && (mouse.y > 48)) {
return;
}
this.stageState == 'none'
game.states.switchState('levelSelector');
}
state.buttonReleased = function(sprite) {
if (this.stageState == 'init') {
this.activateScene();
@@ -294,7 +307,6 @@ state.checkCollision = function () {
if ((this.character.physics.velocity.x == 0) && (this.character.physics.velocity.y == 0)) {
if (this.stageState == 'running') {
this.stageState = 'stop';
this.myButton.text = 'Restart'
}
return;
}