local storyboard = require( "storyboard" ) local scene = storyboard.newScene() -- To create New Scene
local widget = require "widget" -- To create widget
function scene:createScene( event ) local group = self.view local soundsMusic = audio.loadStream( "sounds/daddy.mp3" )
local button1 = widget.newButton -- To create Button1
{
width = 90, height = 45, defaultFile = "play_off1.png", overFile = "play_on1.png", onEvent = handleButtonEvent
}
group:insert ( button1 ) -- To insert Button1 into group
local button2 = widget.newButton -- To create Button2
{
width = 90, height = 45, defaultFile = "off_1.png", overFile = "on_1.png", onEvent = handleButtonEvent
}
group:insert ( button2 ) -- To insert Button1 into group
-- Function to handle button events
local daddyMusic = true
local function onTap( event ) -- FOR ON/OFF BUTTON
local group = self.view
end
button2:addEventListener( "tap", onTap )
local button3 = widget.newButton -- To create Button2
{
width = 90, height = 45, defaultFile = "about_off1.png", overFile = "about_on1.png", onEvent = handleButtonEvent
}
group:insert( button3) -- To insert Button3 into group
-- Function to handle button events
local function onTap( event ) -- FOR About BUTTON
local group = self.view
-- To add NEW IMAGE background
local image = display.newImageRect( "about.png", 300, 250 ) image.x = display.contentCenterX image.y = display.contentCenterY
storyboard.gotoScene( "about", { effect= "slideLeft"}) -- To move to About Scene
return true
end
button3:addEventListener( "tap", onTap )
local button4 = widget.newButton -- To create Button4
{
width = 90, height = 45, defaultFile = "help_off1.png", overFile = "help_on1.png", onEvent = handleButtonEvent
}
group:insert( button4) -- To insert Button4 into group
-- Function to handle button events
local function onTap( event ) -- FOR Help BUTTON
local group = self.view
-- To add NEW IMAGE background
local image = display.newImageRect( "help.png", 300, 250 ) image.x = display.contentCenterX image.y = display.contentCenterY
storyboard.gotoScene( "help", { effect= "slideLeft"}) -- To move to About Scene
return true
end
button4:addEventListener( "tap", onTap )
-- Function to handle button events
local function onTap( event ) -- FOR PLAY BUTTON
local group = self.view
-- To add NEW IMAGE background
local image = display.newImageRect( "bg.png", 569, 320 ) image.x = display.contentCenterX image.y = display.contentCenterY
-- Play the music “daddy.mp3"
-- Define music variables
local daddyMusic = audio.loadStream( "sounds/daddy.mp3" )
-- Play the music
local daddyMusicChannel = audio.play( daddyMusic, {channel=1,loops = 3 } )
-- CIRCLE CODE HERE
-- COUNTER DECLARATION
local globalcount = 0
local function playOneMore ()
if(globalcount == 5) then
local laserSound = audio.loadSound("sounds/onemore1.mp3") local laserChannel = audio.play( laserSound ) end
end
-- CIRCLE 1 -- CIRCLE
-- CIRCLE 1
local circle1 = display.newImageRect( "circle_1.png", 79, 79 ) circle1.x = 167 circle1.y = 90 local function myTapListener( event ) circle1:setFillColor(1, 0, 2 ) -- GREEN RECT(Top Left)
-- To play the beep sound
local mySoundEffect = audio.loadSound("sounds/beep.caf") audio.play(mySoundEffect)
count1 = 1
globalcount = globalcount + count1
playOneMore ()
return circle1
end
circle1:addEventListener( "tap", myTapListener )
-- CIRCLE 2
local circle2 = display.newImageRect( "circle_1.png", 79, 79 ) circle2.x = 0 circle2.y = 159 local function myTapListener( event ) circle2:setFillColor(1, 0, 2 ) -- GREEN RECT(Top Left)
-- To play the beep sound
local mySoundEffect = audio.loadSound("sounds/beep.caf") audio.play(mySoundEffect)
count2 = 1
globalcount = globalcount + count2
playOneMore ()
return circle2
end
circle2:addEventListener( "tap", myTapListener )
-- CIRCLE 3
local circle3 = display.newImageRect( "circle_off_2.png", 46, 46 ) circle3.x = 205 circle3.y = 270 local function myTapListener( event ) circle3:setFillColor(1, 0, 2 ) -- GREEN RECT(Top Left)
-- To play the beep sound
local mySoundEffect = audio.loadSound("sounds/beep.caf") audio.play(mySoundEffect)
count3 = 1
globalcount = globalcount + count3
playOneMore ()
return circle3
end
circle3:addEventListener( "tap", myTapListener )
-- CIRCLE 4
local circle4 = display.newImageRect( "circle_off_3.png", 67, 67 ) circle4.x = 294 circle4.y = 244 -- down local function myTapListener( event ) circle4:setFillColor(0, 1, 1 ) -- GREEN RECT(Top Left)
-- To play the beep sound
local mySoundEffect = audio.loadSound("sounds/beep.caf") audio.play(mySoundEffect)
count4 = 1
globalcount = globalcount + count4
playOneMore ()
return circle4
end
circle4:addEventListener( "tap", myTapListener )
-- CIRCLE 5
local circle5 = display.newImageRect( "circle_off_4.png", 67, 67 ) circle5.x = 485 circle5.y = 237 -- down local function myTapListener( event ) circle5:setFillColor(0, 1, 1 ) -- GREEN RECT(Top Left)
-- To play the beep sound
local mySoundEffect = audio.loadSound("sounds/beep.caf") audio.play(mySoundEffect)
count5 = 1
globalcount = globalcount + count5
playOneMore ()
return circle5
end
circle5:addEventListener( "tap", myTapListener )
-- CIRCLE 6
local circle6 = display.newImageRect( "circle_off_5.png", 40, 40 ) circle6.x = 140 circle6.y = 219 -- down local function myTapListener( event ) circle6:setFillColor(0, 1, 2) -- GREEN RECT(Top Left)
-- To play the beep sound
local mySoundEffect = audio.loadSound("sounds/beep.caf") audio.play(mySoundEffect)
count6 = 1
globalcount = globalcount + count6
playOneMore ()
return circle6
end
circle6:addEventListener( "tap", myTapListener )
storyboard.gotoScene( "level1Q3", { effect= "slideLeft"}) -- To move to level1Q3 Scene
return true
end
button1:addEventListener( "tap", onTap )
-- LEFT the PLAY button
button1.x = 70 button1.y = 90
-- ON and OFF button
button2.x = 227 button2.y = 89
-- About button
button3.x = 385 button3.y = 89
-- Help button
button4.x = 70 button4.y = 220
end
function scene:enterScene( event ) local group = self.view
end function scene:exitScene( event ) local group = self.view
end
function scene:destroyScene( event ) local group = self.view
end
scene:addEventListener( "createScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "destroyScene", scene )
return scene