From 47459f1b61e8f03d88bc1bd3cf777d08a40f9b90 Mon Sep 17 00:00:00 2001 From: niku Date: Sat, 7 Mar 2015 04:56:16 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=81=A7=E5=88=A9=E7=94=A8=E3=81=99=E3=82=8B=E7=94=BB=E5=83=8F?= =?UTF-8?q?=E3=82=92=E3=83=AA=E3=82=BD=E3=83=BC=E3=82=B9=E3=81=B8=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/resource.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/resource.js b/src/resource.js index 9428ada..0e6de63 100644 --- a/src/resource.js +++ b/src/resource.js @@ -7,7 +7,11 @@ var res = { "res/images/fruit2.png", "res/images/fruit3.png", "res/images/fruit4.png" - ] + ], + replayButton: "res/images/replay_button.png", + replayButtonPressed: "res/images/replay_button_pressed.png", + titleButton: "res/images/title_button.png", + titleButtonPressed: "res/images/title_button_pressed.png" }; var g_resources = []; From 09367d46a9d6b3b13803a029c7f8a005a80e56b5 Mon Sep 17 00:00:00 2001 From: niku Date: Sat, 7 Mar 2015 05:40:17 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=82=B2=E3=83=BC=E3=83=A0=E7=B5=82?= =?UTF-8?q?=E4=BA=86=E5=BE=8C=E3=81=AB=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main-scene.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main-scene.js b/src/main-scene.js index 324d1c6..8bb4255 100644 --- a/src/main-scene.js +++ b/src/main-scene.js @@ -138,6 +138,7 @@ var MainSceneLayer = cc.Layer.extend({ if(this.second_ < 0) { // リザルト状態へ移行 this.state_ = MainSceneLayer.GameState["RESULT"]; + this.onResult(); } } }, @@ -198,7 +199,35 @@ var MainSceneLayer = cc.Layer.extend({ this.removeFruit(fruit); this.score_ += 1; this.scoreLabel_.setString(cc.formatStr("%d", this.score_)); - } + }, + + onResult: function() { + this.state_ = MainSceneLayer.GameState["RESULT"]; + var winSize = cc.director.getWinSize(); + + // 「もう一度遊ぶ」ボタン + var replayButton = new cc.MenuItemImage(res.replayButton, + res.replayButtonPressed, + function() { + var scene = new MainScene(); + cc.director.runScene(scene); + }); + + // 「タイトルへ戻る」ボタン + var titleButton = new cc.MenuItemImage(res.titleButton, + res.titleButtonPressed, + function() { + // 「タイトルへ戻る」ボタンを押したときの処理 + // いまは何も実装していない + }); + + // 2つのボタンからメニューを作成する + var menu = new cc.Menu(replayButton, titleButton); + // ボタンを縦に並べる + menu.alignItemsVerticallyWithPadding(15); // ボタンを縦に並べる + menu.setPosition(cc.p(winSize.width / 2.0, winSize.height / 2.0)); + this.addChild(menu); + }, }); MainSceneLayer.FruitType = [ "APPLE",