I Have made one lua file which consist of multiple and transition using touch event listener but i want to perform tap event on this also to go from one scene to another scene.
I added all assets in this scene into one group and then performed transitions but i want tap event to perform on particular object but its not working. what could be the reason.
see attached file also
Code is::
local composer=require(“composer”)
local fontname=“Space Marine”
local dataParser = require( “gameData” )
local gameData = dataParser.setGameData()
local scene=composer.newScene()
local function gotoScene()
print(“prntinfdnc”)
composer.gotoScene(“area1levels”)
end
local function gotonextareascreen(event)
local area1gp=event.target
local phase=event.phase
if “began”==phase then
display.getCurrentStage():setFocus(area1gp)
area1gp.isFocus=true
initx=event.x
inity=event.y
area1gp.x0=event.x-area1gp.x
area1gp.y0=event.y-area1gp.y
–print(initx)
else
if “moved”==phase then
area1gp.x =event.x-area1gp.x0
area1gp.y=0
–planet_red.x=planet_red+area1gp.x
elseif “ended”==phase or “cancelled”==phase then
newx=event.x
newy=event.y
–print(newx)
a=event.x-initx
–print(a)
if(a>-150) then
local t1= transition.to(area1gp,{time=300,x=0,onComplete=function()
onarea1.isVisible=true
onarea2.isVisible=false
onarea3.isVisible=false
onarea4.isVisible=false
onarea5.isVisible=false
transition.cancel()
end})
end
if(a<=-150) then
–area1gp.x=-display.contentWidth
local t2=transition.to(area1gp,{time=300,x=-display.contentWidth,onComplete= function()
area1gp:removeEventListener(“touch”,gotonextareascreen)
onarea1.isVisible=false
onarea2.isVisible=true
onarea3.isVisible=false
onarea4.isVisible=false
onarea5.isVisible=false
– starsgp.isVisible=false
area1gp:removeEventListener(“tap”,gotoScene)
area1gp:addEventListener(“touch”,gotonextareascreen2)
–transition.cancel(t2)
transition.cancel()
end
})--
– transition.to(area2gp,{time=500,x=-display.contentWidth})
display.getCurrentStage():setFocus(nil)
area1gp.isFocus=false
end
end
end
return true
end
function gotonextareascreen2(event)
–print(“entered in next touch”)
local area1gp=event.target
local phase=event.phase
if “began”==phase then
display.getCurrentStage():setFocus(area1gp)
area1gp.isFocus=true
initx=event.x
inity=event.y
area1gp.x0=event.x-area1gp.x
area1gp.y0=event.y-area1gp.y
–event.target.bodyType=“kinematic”
–print("intialx "…initx)
else
if “moved”==phase then
area1gp.x =event.x-area1gp.x0
area1gp.y=0
–planet_red.x=planet_red+area1gp.x
elseif “ended”==phase or “cancelled”==phase then
newx=event.x
newy=event.y
–print("final x "…newx)
a=event.x-initx
–print(“subtract”…a)
if(a>-150 and a<=150) then
local t3=transition.to(area1gp,{time=300,x=-display.contentWidth,onComplete=function()
onarea1.isVisible=false
onarea2.isVisible=true
onarea3.isVisible=false
onarea4.isVisible=false
onarea5.isVisible=false
–transition.cancel(t3)
transition.cancel()
end})
end
if(a<=-150) then
–area1gp.x=-display.contentWidth
local t4=transition.to(area1gp,{time=300,x=-2*display.contentWidth,onComplete= function()
area1gp:removeEventListener(“touch”,gotonextareascreen2)
onarea1.isVisible=false
onarea2.isVisible=false
onarea3.isVisible=true
onarea4.isVisible=false
onarea5.isVisible=false
area1gp:addEventListener(“touch”,gotonextareascreen3)
–transition.cancel(t4)
transition.cancel()
display.getCurrentStage():setFocus(nil)
area1gp.isFocus=false
end
})–
– transition.to(area2gp,{time=500,x=-display.contentWidth})
elseif (a>150) then
local t5=transition.to(area1gp,{time=300,x=0,onComplete= function()
area1gp:removeEventListener(“touch”,gotonextareascreen2)
area1gp:addEventListener(“tap”,gotoScene)
onarea1.isVisible=true
onarea2.isVisible=false
onarea3.isVisible=false
onarea4.isVisible=false
onarea5.isVisible=false
area1gp:addEventListener(“touch”,gotonextareascreen)
–transition.cancel(t5)
transition.cancel()
display.getCurrentStage():setFocus(nil)
area1gp.isFocus=false
end})
end
end
end
return true
end
function gotonextareascreen3(event)
–print(“entered in next touch”)
local area1gp=event.target
local phase=event.phase
if “began”==phase then
display.getCurrentStage():setFocus(area1gp)
area1gp.isFocus=true
initx=event.x
inity=event.y
area1gp.x0=event.x-area1gp.x
area1gp.y0=event.y-area1gp.y
–event.target.bodyType=“kinematic”
–print("intialx "…initx)
else
if “moved”==phase then
area1gp.x =event.x-area1gp.x0
area1gp.y=0
–planet_red.x=planet_red+area1gp.x
elseif “ended”==phase or “cancelled”==phase then
newx=event.x
newy=event.y
–print("final x "…newx)
a=event.x-initx
–print(“subtract”…a)
if(a>-150 and a<=150) then
local t6=transition.to(area1gp,{time=300,x=-2*display.contentWidth,onComplete=function()
onarea1.isVisible=false
onarea2.isVisible=false
onarea3.isVisible=true
onarea4.isVisible=false
onarea5.isVisible=false
–transition.cancel(t6)
transition.cancel()
end})
end
if(a<=-150) then
–area1gp.x=-display.contentWidth
local t7= transition.to(area1gp,{time=300,x=-3*display.contentWidth,onComplete= function()
area1gp:removeEventListener(“touch”,gotonextareascreen3)
onarea1.isVisible=false
onarea2.isVisible=false
onarea3.isVisible=false
onarea4.isVisible=true
onarea5.isVisible=false
area1gp:addEventListener(“touch”,gotonextareascreen4)
–transition.cancel(t7)
transition.cancel()
display.getCurrentStage():setFocus(nil)
area1gp.isFocus=false
end
})–
– transition.to(area2gp,{time=500,x=-display.contentWidth})
elseif (a>150) then
local t8=transition.to(area1gp,{time=300,x=-display.contentWidth,onComplete= function()
area1gp:removeEventListener(“touch”,gotonextareascreen3)
onarea1.isVisible=false
onarea2.isVisible=true
onarea3.isVisible=false
onarea4.isVisible=false
onarea5.isVisible=false
area1gp:addEventListener(“touch”,gotonextareascreen2)
–transition.cancel(t8)
transition.cancel()
display.getCurrentStage():setFocus(nil)
area1gp.isFocus=false
end})
end
end
end
return true
end
function gotonextareascreen4(event)
–print(“entered in next touch”)
local area1gp=event.target
local phase=event.phase
if “began”==phase then
display.getCurrentStage():setFocus(area1gp)
area1gp.isFocus=true
initx=event.x
inity=event.y
area1gp.x0=event.x-area1gp.x
area1gp.y0=event.y-area1gp.y
–event.target.bodyType=“kinematic”
–print("intialx "…initx)
else
if “moved”==phase then
area1gp.x =event.x-area1gp.x0
area1gp.y=0
–planet_red.x=planet_red+area1gp.x
elseif “ended”==phase or “cancelled”==phase then
newx=event.x
newy=event.y
–print("final x "…newx)
a=event.x-initx
–print(“subtract”…a)
if(a>-150 and a<=150) then
local t9=transition.to(area1gp,{time=300,x=-3*display.contentWidth,onComplete=function()
onarea1.isVisible=false
onarea2.isVisible=false
onarea3.isVisible=false
onarea4.isVisible=true
onarea5.isVisible=false
–transition.cancel(t9)
transition.cancel()
end})
end
if(a<=-150) then
–area1gp.x=-display.contentWidth
local t10=transition.to(area1gp,{time=300,x=-4*display.contentWidth,onComplete= function()
area1gp:removeEventListener(“touch”,gotonextareascreen4)
onarea1.isVisible=false
onarea2.isVisible=false
onarea3.isVisible=false
onarea4.isVisible=false
onarea5.isVisible=true
area1gp:addEventListener(“touch”,gotonextareascreen5)
–transition.cancel(t10)
transition.cancel()
display.getCurrentStage():setFocus(nil)
area1gp.isFocus=false
end
})–
– transition.to(area2gp,{time=500,x=-display.contentWidth})
elseif (a>150) then
local t11=transition.to(area1gp,{time=300,x=-2*display.contentWidth,onComplete= function()
area1gp:removeEventListener(“touch”,gotonextareascreen4)
onarea1.isVisible=false
onarea2.isVisible=false
onarea3.isVisible=true
onarea4.isVisible=false
onarea5.isVisible=false
area1gp:addEventListener(“touch”,gotonextareascreen3)
–transition.cancel(11)
transition.cancel()
display.getCurrentStage():setFocus(nil)
area1gp.isFocus=false
end})
end
end
end
return true
end
function gotonextareascreen5(event)
–print(“entered in next touch”)
local area1gp=event.target
local phase=event.phase
if “began”==phase then
display.getCurrentStage():setFocus(area1gp)
area1gp.isFocus=true
initx=event.x
inity=event.y
area1gp.x0=event.x-area1gp.x
area1gp.y0=event.y-area1gp.y
–event.target.bodyType=“kinematic”
–print("intialx "…initx)
else
if “moved”==phase then
area1gp.x =event.x-area1gp.x0
area1gp.y=0
–planet_red.x=planet_red+area1gp.x
elseif “ended”==phase or “cancelled”==phase then
newx=event.x
newy=event.y
–print("final x "…newx)
a=event.x-initx
–print(“subtract”…a)
if(a<150) then
local t12=transition.to(area1gp,{time=300,x=-4*display.contentWidth,onComplete=function()
onarea1.isVisible=false
onarea2.isVisible=false
onarea3.isVisible=false
onarea4.isVisible=false
onarea5.isVisible=true
transition.cancel()
– transition.cancel(t12)
end})
end
if (a>=150) then
local t13=transition.to(area1gp,{time=300,x=-3*display.contentWidth,onComplete= function()
area1gp:removeEventListener(“touch”,gotonextareascreen5)
onarea1.isVisible=false
onarea2.isVisible=false
onarea3.isVisible=false
onarea4.isVisible=true
onarea5.isVisible=false
transition.cancel()
area1gp:addEventListener(“touch”,gotonextareascreen4)
display.getCurrentStage():setFocus(nil)
area1gp.isFocus=false
–transition.cancel(13)
end})
end
end
end
return true
end
function scene:create(event)
local group=self.view
– local gameData=dataParser.setGameData()
– local gameData=dataParser.getGameData()
area1gp=display.newGroup()
– area2gp=display.newGroup()
– area3gp=display.newGroup()
local starsgp=display.newGroup()
local bg=display.newImageRect(“images/bg.png”,1280,720)
bg.x = 640
bg.y = 360
–[[ new=display.newRect(100,400,100,100)
new:setFillColor(1,1,1) --]]
local bgfrontrect=display.newRect(display.contentWidth*0.5,display.contentHeight*0.5,12*1280,721)
bgfrontrect:setFillColor(1,0,0)
bgfrontrect.isVisible=false
bgfrontrect.isHitTestable=true
– local text1=display.newText(“THE”,100,100,display.contentWidth*0.5,100,fontname,35)
local options =
{
--parent = textGroup,
text =[[THE
]],
x = display.contentWidth*0.5,
y = 50,
width = 128, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 36,
align = “center” --new alignment parameter
}
text1 = display.newText( options )
–local text1=display.newText(“THE”,display.contentWidth*0.5,50,fontname,35)
local options1 =
{
--parent = textGroup,
text =[[RED PLANET
]],
x = display.contentWidth*0.5,
y = 100,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 48,
align = “center” --new alignment parameter
}
local text2 = display.newText( options1 )
–local text2=display.newText(“RED PLANET”,display.contentWidth*0.5,100,fontname,48)
planet_red=display.newImageRect(“images/planet_red.png”,400,400)
planet_red.x=display.contentWidth*0.5
planet_red.y=300
area1cleared=display.newImageRect(“images/area1clear.png”,500,500)
area1cleared.x=display.contentWidth*0.5
area1cleared.y=300
area1cleared.rotation=25
area1cleared.isVisible=false
local scoreframe=display.newImageRect(“images/score_frame_big.png”,600,240)
scoreframe.x=display.contentWidth*0.5
scoreframe.y=500
local i=1
–for i=1,5 do
local starfilled3 = display.newImageRect(“images/star1.png”,94,97)
starfilled3.x = i*(450-10)
–print(starfilled3.x)
starfilled3.y = (display.contentHeight*0.5+140)-10
– starfilled3.isVisible = false
local starfilled4 = display.newImageRect(“images/star2.png”,114,117)
starfilled4.x = i*(450+60)
starfilled4.y = i*(display.contentHeight*0.5+140 )-10
–starfilled4.isVisible = false
local starfilled5 = display.newImageRect(“images/star1.png”,94,97)
starfilled5.x = i*(450+130 )
starfilled5.y = i*(display.contentHeight*0.5+140 )-10
–starfilled5.isVisible = false
starsgp:insert(starfilled3)
starsgp:insert(starfilled4)
starsgp:insert(starfilled5)
–end
local options3 =
{
--parent = textGroup,
text =[[ / 30
]],
x = text1.x+140,
y = display.contentHeight*0.5+157,
width = 260, --required for multi-line and alignment
font = fontname,
height=80,
fontSize = 48,
align = “center” --new alignment parameter
}
local text15 = display.newText( options3 )
–local text15=display.newText(" / 30",text1.x+140,display.contentHeight*0.5+140,fontname,45)
local options4 =
{
--parent = textGroup,
text =[[COMING
]],
x = 1.5*display.contentWidth,
y = 60,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 60,
align = “center” --new alignment parameter
}
local text3=display.newText(options4)
local options5 =
{
--parent = textGroup,
text =[[SOON
]],
x = display.contentWidth*0.5+display.contentWidth,
y = 110,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 48,
align = “center” --new alignment parameter
}
local text4=display.newText(options5)
–local text4=display.newText(“SOON”,display.contentWidth*0.5+display.contentWidth,100,fontname,48)
text3:setFillColor(128/255,128/255,128/255)
text4:setFillColor(128/255,128/255,128/255)
local options6 =
{
--parent = textGroup,
text =[[THE
]],
x = display.contentWidth*0.5+display.contentWidth,
y = display.contentHeight-180,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 36,
align = “center” --new alignment parameter
}
local text16=display.newText(options6)
local options7 =
{
--parent = textGroup,
text =[[GREY PLANET
]],
x = display.contentWidth*0.5+display.contentWidth,
y = display.contentHeight-130,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 48,
align = “center” --new alignment parameter
}
local text17=display.newText(options7)
– local text16=display.newText(“THE”,display.contentWidth*0.5+display.contentWidth,display.contentHeight-200,fontname,35)
–local text17=display.newText(“GREY PLANET”,display.contentWidth*0.5+display.contentWidth,display.contentHeight-150,fontname,48)
text17:setFillColor(128/255,128/255,128/255)
text16:setFillColor(128/255,128/255,128/255)
local planet_grey=display.newImageRect(“images/planet_grey.png”,400,400)
planet_grey.x=planet_red.x+display.contentWidth
planet_grey.y=310
–[[
local scoreframe1=display.newImageRect(“images/score_frame_big.png”,600,240)
scoreframe1.x=scoreframe.x+display.contentWidth
scoreframe1.y=500
–local i=2
local starfilled6 = display.newImageRect(“images/star1.png”,94,97)
starfilled6.x = (450-10) +display.contentWidth
–print(starfilled3.x)
starfilled6.y = (display.contentHeight*0.5+130)
– starfilled3.isVisible = false
local starfilled7 = display.newImageRect(“images/star2.png”,114,117)
starfilled7.x = (450+60)+display.contentWidth
starfilled7.y = (display.contentHeight*0.5+130 )
–starfilled4.isVisible = false
local starfilled8 = display.newImageRect(“images/star1.png”,94,97)
starfilled8.x = (450+130 )+display.contentWidth
starfilled8.y = (display.contentHeight*0.5+130 )
–starfilled5.isVisible = false
starsgp:insert(starfilled6)
starsgp:insert(starfilled7)
starsgp:insert(starfilled8)
–]]
local options20 =
{
--parent = textGroup,
text =[[COMING
]],
x = 1.5*display.contentWidth+display.contentWidth,
y = 70,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 60,
align = “center” --new alignment parameter
}
local text5=display.newText(options20)
local options21 =
{
--parent = textGroup,
text =[[SOON
]],
x = display.contentWidth*0.5+display.contentWidth+display.contentWidth,
y = 120,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 48,
align = “center” --new alignment parameter
}
local text6=display.newText(options21)
– local text5=display.newText(“COMING”,1.5*display.contentWidth+display.contentWidth,50,fontname,52)
– local text6=display.newText(“SOON”,display.contentWidth*0.5+display.contentWidth+display.contentWidth,100,fontname,48)
local planet_grey1=display.newImageRect(“images/planet_black.png”,400,400)
planet_grey1.x=planet_grey.x+display.contentWidth
planet_grey1.y=350
–[[local scoreframe2=display.newImageRect(“images/score_frame_big.png”,600,240)
scoreframe2.x=scoreframe1.x+display.contentWidth
scoreframe2.y=500 --]]
–[[ local options8 =
{
--parent = textGroup,
x = 10+display.contentWidth*0.5+display.contentWidth+display.contentWidth+10,
y = 385,
width = 600, --required for multi-line and alignment
font = fontname,
–height=120,
fontSize = 84,
align = “center” --new alignment parameter
}
local text11=display.newText(options8) ]]
local text11=display.newImageRect(“images/question.png”,84,84)
text11.x=display.contentWidth*0.5+display.contentWidth+display.contentWidth
text11.y=355
–local text11=display.newText("?",display.contentWidth*0.5+display.contentWidth+display.contentWidth,350,fontname,78)
–[[ local starfilled1 = display.newImageRect(“images/star1.png”,94,97)
starfilled1.x = (450-10) +(2*display.contentWidth)
–print(starfilled3.x)
starfilled1.y = (display.contentHeight*0.5+130)
– starfilled3.isVisible = false
local starfilled2 = display.newImageRect(“images/star2.png”,114,117)
starfilled2.x = (450+60)+(2*display.contentWidth)
starfilled2.y = (display.contentHeight*0.5+130 )
–starfilled4.isVisible = false
local starfilled3 = display.newImageRect(“images/star1.png”,94,97)
starfilled3.x = (450+130 )+(2*display.contentWidth)
starfilled3.y = (display.contentHeight*0.5+130 )
–starfilled5.isVisible = false
starsgp:insert(starfilled1)
starsgp:insert(starfilled2)
starsgp:insert(starfilled3) --]]
local options9 =
{
--parent = textGroup,
text =[[COMING
]],
x = 1.5*display.contentWidth+display.contentWidth+display.contentWidth,
y = 70,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 60,
align = “center” --new alignment parameter
}
local text7=display.newText(options9)
local options10 =
{
--parent = textGroup,
text =[[SOON
]],
x = display.contentWidth*0.5+display.contentWidth+display.contentWidth+display.contentWidth,
y = 120,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 48,
align = “center” --new alignment parameter
}
local text8=display.newText(options10)
–local text7=display.newText(“COMING”,1.5*display.contentWidth+display.contentWidth+display.contentWidth,50,fontname,52)
–local text8=display.newText(“SOON”,display.contentWidth*0.5+display.contentWidth+display.contentWidth+display.contentWidth,100,fontname,48)
local planet_grey2=display.newImageRect(“images/planet_black.png”,400,400)
planet_grey2.x=planet_grey1.x+display.contentWidth
planet_grey2.y=350
–[[local scoreframe3=display.newImageRect(“images/score_frame_big.png”,600,240)
scoreframe3.x=scoreframe2.x+display.contentWidth
scoreframe3.y=500–]]
–[[ local options11 =
{
--parent = textGroup,
x = 20+display.contentWidth*0.5+display.contentWidth+display.contentWidth+display.contentWidth,
y = 385,
width = 100, --required for multi-line and alignment
font = fontname,
– height=120,
fontSize = 72,
align = “center” --new alignment parameter
}
]]
– local text12=display.newText(options11)
local text12=display.newImageRect(“images/question.png”,84,84)
text12.x=display.contentWidth*0.5+display.contentWidth+display.contentWidth+display.contentWidth
text12.y=355
–local text12=display.newText("?",display.contentWidth*0.5+display.contentWidth+display.contentWidth+display.contentWidth,350,fontname,78)
–[[local starfilled9 = display.newImageRect(“images/star1.png”,94,97)
starfilled9.x = (450-10) +(3*display.contentWidth)
–print(starfilled3.x)
starfilled9.y = (display.contentHeight*0.5+130)
– starfilled3.isVisible = false
local starfilled10 = display.newImageRect(“images/star2.png”,114,117)
starfilled10.x = (450+60)+(3*display.contentWidth)
starfilled10.y = (display.contentHeight*0.5+130 )
–starfilled4.isVisible = false
local starfilled11 = display.newImageRect(“images/star1.png”,94,97)
starfilled11.x = (450+130 )+(3*display.contentWidth)
starfilled11.y = (display.contentHeight*0.5+130 )
–starfilled5.isVisible = false
starsgp:insert(starfilled9)
starsgp:insert(starfilled10)
starsgp:insert(starfilled11)–]]
local options12 =
{
--parent = textGroup,
text =[[COMING
]],
x = 1.5*display.contentWidth+display.contentWidth+display.contentWidth+display.contentWidth,
y = 70,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 60,
align = “center” --new alignment parameter
}
local text9=display.newText(options12)
local options13 =
{
--parent = textGroup,
text =[[SOON
]],
x = 1.5*display.contentWidth+display.contentWidth+display.contentWidth+display.contentWidth,
y = 120,
width = 600, --required for multi-line and alignment
font = fontname,
– height=30,
fontSize = 48,
align = “center” --new alignment parameter
}
local text10=display.newText(options13)
– local text9=display.newText(“COMING”,1.5*display.contentWidth+display.contentWidth+display.contentWidth+display.contentWidth,50,fontname,52)
–local text10=display.newText(“SOON”,text8.x+display.contentWidth,100,fontname,48)
local planet_grey3=display.newImageRect(“images/planet_black.png”,400,400)
planet_grey3.x=planet_grey2.x+display.contentWidth
planet_grey3.y=350
–[[local scoreframe4=display.newImageRect(“images/score_frame_big.png”,600,240)
scoreframe4.x=scoreframe3.x+display.contentWidth
scoreframe4.y=500 --]]
–[[ local options14 =
{
--parent = textGroup,
x = 20+display.contentWidth*0.5+display.contentWidth+display.contentWidth+display.contentWidth+display.contentWidth,
y = 385,
width = 100, --required for multi-line and alignment
font = fontname,
height=120,
fontSize = 72,
align = “center” --new alignment parameter
}
local text13=display.newText(options14) ]]
local text13=display.newImageRect(“images/question.png”,84,84)
text13.x=display.contentWidth*0.5+display.contentWidth+display.contentWidth+2*display.contentWidth
text13.y=355
– local text13=display.newText("?",display.contentWidth*0.5+display.contentWidth+display.contentWidth+display.contentWidth+display.contentWidth,350,fontname,78)
–[[local starfilled12 = display.newImageRect(“images/star1.png”,94,97)
starfilled12.x = (450-10) +(4*display.contentWidth)
–print(starfilled3.x)
starfilled12.y = (display.contentHeight*0.5+130)
– starfilled3.isVisible = false
local starfilled13 = display.newImageRect(“images/star2.png”,114,117)
starfilled13.x = (450+60)+(4*display.contentWidth)
starfilled13.y = (display.contentHeight*0.5+130 )
–starfilled4.isVisible = false
local starfilled14 = display.newImageRect(“images/star1.png”,94,97)
starfilled14.x = (450+130 )+(4*display.contentWidth)
starfilled14.y = (display.contentHeight*0.5+130 )
–starfilled5.isVisible = false
starsgp:insert(starfilled12)
starsgp:insert(starfilled13)
starsgp:insert(starfilled14) --]]
local area1=display.newImageRect(“images/empty.png”,54,50)
area1.x=display.contentWidth*0.5-200
area1.y=display.contentHeight*0.5+320
local area2=display.newImageRect(“images/empty.png”,54,50)
area2.x=display.contentWidth*0.5-100
area2.y=display.contentHeight*0.5+320
local area3=display.newImageRect(“images/empty.png”,54,50)
area3.x=display.contentWidth*0.5
area3.y=display.contentHeight*0.5+320
local area4=display.newImageRect(“images/empty.png”,54,50)
area4.x=display.contentWidth*0.5+100
area4.y=display.contentHeight*0.5+320
local area5=display.newImageRect(“images/empty.png”,54,50)
area5.x=display.contentWidth*0.5+200
area5.y=display.contentHeight*0.5+320
onarea1=display.newImageRect(“images/filled.png”,54,50)
onarea1.x=display.contentWidth*0.5-200
onarea1.y=display.contentHeight*0.5+320
onarea1.isVisible=true
onarea2=display.newImageRect(“images/filled.png”,54,50)
onarea2.x=display.contentWidth*0.5-100
onarea2.y=display.contentHeight*0.5+320
onarea2.isVisible=false
onarea3=display.newImageRect(“images/filled.png”,54,50)
onarea3.x=display.contentWidth*0.5
onarea3.y=display.contentHeight*0.5+320
onarea3.isVisible=false
onarea4=display.newImageRect(“images/filled.png”,54,50)
onarea4.x=display.contentWidth*0.5 + 100
onarea4.y=display.contentHeight*0.5+320
onarea4.isVisible=false
onarea5=display.newImageRect(“images/filled.png”,54,50)
onarea5.x=display.contentWidth*0.5 +200
onarea5.y=display.contentHeight*0.5+320
onarea5.isVisible=false
–local i=1
scene.view:insert(bg)
area1gp:insert(starsgp)
area1gp:insert(bgfrontrect)
area1gp:insert(text1)
area1gp:insert(text2)
area1gp:insert(planet_red)
area1gp:insert(area1cleared)
area1gp:insert(scoreframe)
–area1gp:insert(text14)
area1gp:insert(text15)
area1gp:insert(text3)
area1gp:insert(text4)
area1gp:insert(planet_grey)
area1gp:insert(text16)
area1gp:insert(text17)
–area1gp:insert(scoreframe1)
area1gp:insert(text5)
area1gp:insert(text6)
area1gp:insert(planet_grey1)
–area1gp:insert(scoreframe2)
area1gp:insert(text11)
area1gp:insert(text7)
area1gp:insert(text8)
area1gp:insert(planet_grey2)
–area1gp:insert(scoreframe3)
area1gp:insert(text12)
area1gp:insert(text9)
area1gp:insert(text10)
area1gp:insert(planet_grey3)
–area1gp:insert(scoreframe4)
area1gp:insert(text13)
scene.view:insert(area1gp)
– starsgp:insert(starfilled3)
–starsgp:insert(starfilled4)
– starsgp:insert(starfilled5)
–starsgp.isVisible=false
scene.view:insert(area1)
scene.view:insert(area2)
scene.view:insert(area3)
scene.view:insert(area4)
scene.view:insert(area5)
scene.view:insert(onarea1)
scene.view:insert(onarea2)
scene.view:insert(onarea3)
scene.view:insert(onarea4)
scene.view:insert(onarea5)
–scene.view:insert(starsgp)
end
function scene:show(event)
local group=self.view
if(event.phase==“will”) then
local gameData = dataParser.setGameData()
local gameData=dataParser.getGameData()
if(gameData[10]~=-1 and gameData[13]==1) then
planet_red.isVisible=false
area1cleared.isVisible=true
end
local options2 =
{
--parent = textGroup,
text=[[00
]],
x = display.contentWidth*0.5+50,
y = display.contentHeight*0.5+157,
width = 130, --required for multi-line and alignment
font = fontname,
height=80,
fontSize = 48,
align = “center” --new alignment parameter
}
text14 = display.newText( options2 )
–text14=display.newText(“00”,display.contentWidth*0.5+50,display.contentHeight*0.5+137,fontname,48)
area1gp:insert(text14)
if(gameData[1]~=0) then
text14.text=text14.text+gameData[1]
end
if(gameData[2] ~= -1) then
text14.text=text14.text+gameData[2]
end
if(gameData[3] ~= -1) then
text14.text=text14.text+gameData[3]
end
if(gameData[4] ~= -1) then
text14.text=text14.text+gameData[4]
end
if(gameData[5] ~= -1) then
text14.text=text14.text+gameData[5]
end
if(gameData[6] ~= -1) then
text14.text=text14.text+gameData[6]
end
if(gameData[7] ~= -1) then
text14.text=text14.text+gameData[7]
end
if(gameData[8] ~= -1) then
text14.text=text14.text+gameData[8]
end
if(gameData[9] ~= -1) then
text14.text=text14.text+gameData[9]
end
if(gameData[10] ~= -1) then
text14.text=text14.text+gameData[10]
–levelBtns[10]:addEventListener(“tap”,levelStart10)
end
elseif(event.phase==“did”) then
local gameData=dataParser.getGameData()
area1gp:addEventListener(“touch”,gotonextareascreen)
–area1gp:addEventListener(“tap”,gotoScene)
–area1cleared:addEventListener(“tap”,gotoScene)
text1:addEventListener(“tap”,gotoScene)
end
end
function scene:hide(event)
local group=self.view
if(event.phase==“will”) then
transition.cancel()
area1gp:removeEventListener(“touch”,gotonextareascreen)
area1gp:removeEventListener(“tap”,gotoScene)
area1gp:removeEventListener(“touch”,gotonextareascreen2)
area1gp:removeEventListener(“touch”,gotonextareascreen3)
area1gp:removeEventListener(“touch”,gotonextareascreen4)
area1gp:removeEventListener(“touch”,gotonextareascreen5)
–circle:removeEventListener(“tap”,gotoAreasbesidesthrowball)
elseif(event.phase==“did”) then
composer.removeScene(“area1”)
end
end
scene:addEventListener(“create”,scene)
scene:addEventListener(“show”,scene)
scene:addEventListener(“hide”,scene)
return scene