From 458a37a2aab1eb331a25753a219dff649ae523aa Mon Sep 17 00:00:00 2001 From: Gabriel Lidenor Date: Thu, 1 Oct 2015 14:25:08 -0300 Subject: [PATCH 1/2] start_game button --- game/FlappyBird/app/main_scene.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/game/FlappyBird/app/main_scene.rb b/game/FlappyBird/app/main_scene.rb index b13656b..fdd09cc 100644 --- a/game/FlappyBird/app/main_scene.rb +++ b/game/FlappyBird/app/main_scene.rb @@ -9,8 +9,7 @@ def initialize add_skyline add_ground - add_bird - + start_game @pipe_update = 0 @random = Random.new @@ -27,7 +26,19 @@ def initialize true end - start_update + end + + def start_game + button_start = MG::Button.new() + button_start.text = "Start Game" + button_start.font_size = 30 + button_start.position = [MG::Director.shared.size.width / 2.0, MG::Director.shared.size.height / 2.0] + button_start.on_touch do |type| + add_bird + start_update + button_start.visible = false + end + add button_start end def add_skyline From b0f01c77c0d89652110b2edd03d03c212a9c75a8 Mon Sep 17 00:00:00 2001 From: Gabriel Lidenor Date: Thu, 1 Oct 2015 15:34:48 -0300 Subject: [PATCH 2/2] start_game button avoid double bird creation --- game/FlappyBird/app/main_scene.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/game/FlappyBird/app/main_scene.rb b/game/FlappyBird/app/main_scene.rb index fdd09cc..173eb60 100644 --- a/game/FlappyBird/app/main_scene.rb +++ b/game/FlappyBird/app/main_scene.rb @@ -34,9 +34,11 @@ def start_game button_start.font_size = 30 button_start.position = [MG::Director.shared.size.width / 2.0, MG::Director.shared.size.height / 2.0] button_start.on_touch do |type| - add_bird - start_update - button_start.visible = false + if type == :end + add_bird + start_update + button_start.visible = false + end end add button_start end