mirror of
https://github.com/ysoftdevs/pf2016.git
synced 2026-03-25 18:42:16 +01:00
add back button
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 163 KiB After Width: | Height: | Size: 164 KiB |
@@ -49,6 +49,11 @@ state.create = function() {
|
|||||||
|
|
||||||
// Sky layer
|
// Sky layer
|
||||||
this.addChild(this.tilemap.layers[2]);
|
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
|
// Create collision layer
|
||||||
for(var i = 21; i < this.tilemap.tileTypes.length; i++) {
|
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 );
|
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) {
|
state.buttonReleased = function(sprite) {
|
||||||
if (this.stageState == 'init') {
|
if (this.stageState == 'init') {
|
||||||
this.activateScene();
|
this.activateScene();
|
||||||
@@ -294,7 +307,6 @@ state.checkCollision = function () {
|
|||||||
if ((this.character.physics.velocity.x == 0) && (this.character.physics.velocity.y == 0)) {
|
if ((this.character.physics.velocity.x == 0) && (this.character.physics.velocity.y == 0)) {
|
||||||
if (this.stageState == 'running') {
|
if (this.stageState == 'running') {
|
||||||
this.stageState = 'stop';
|
this.stageState = 'stop';
|
||||||
this.myButton.text = 'Restart'
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user