Hi, I am fairly new to corona, I am creating a whack style game using storyboard, everything works except for the fact that once you go to the game screen my images should randomly appear for the user to try and tap(whack) then the next picture appears and so on.
Can someone please help me and tell me as to where i am going wrong.
Here is my level1.lua
[code]
–
– level1.lua
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
function scene:createScene( event )
local group = self.view
background = display.newImage (group, “gamebackground.png”)
– OBJECTS
local p1
local p2
local p3
local p4
local p5
local pollys
local lastPolly = {}
– Variables
local timerSource
local currentPollys = 0
local pollysHit = 0
local totalPollys = 5
– Functions
local showGameView = {}
local preparePollys = {}
local startTimer = {}
local showPolly = {}
local popOut = {}
local pollyHit = {}
local showGameView= function (event)
score = display.newText(‘0’ … ‘/’ … totalPollys, 400, 290, native.systemFontBold, 16)
score:setTextColor(700, 700, 100)
end
showGameView()
local preparePollys = function(event)
p1 = display.newImage(‘Julia.png’, 200, 105)
p2 = display.newImage(‘abbott.png’, 360, 167)
p3 = display.newImage(‘Julia.png’, 360, 40)
p4 = display.newImage(‘abbott.png’, 50, 167)
p5 = display.newImage(‘Julia.png’, 200, 105)
local pollys = display.newGroup(p1, p2, p3, p4, p5)
for i = 1, pollys.numChildren do
pollys[i]:addEventListener(‘tap’, pollyHit)
pollys[i].isVisible = false
end
preparePollys()
end
local startTimer = function()
timerSource = timer.performWithDelay(1400, showPolly, 0)
end
startTimer()
local showPolly = function(event)
if(currentPollys == totalPollys) then
storyboard.gotoScene(“mainmenu”)
else
lastPolly.isVisible = false
local randomHole = math.floor(math.random() * 5) + 1
lastPolly = pollys[randomHole]
lastPolly:setReferencePoint(display.BottomCenterReferencePoint)
lastPolly.yScale = 0.1
lastPolly.isVisible = true
Runtime:addEventListener(‘enterFrame’, popOut)
currentPollys = currentPollys + 1
end
end
local popOut = function(event)
lastPolly.yScale = lastPolly.yScale + 0.2
if(lastPolly.yScale >= 1) then
Runtime:removeEventListener(‘enterFrame’, popOut)
end
end
local pollyHit = function(event)
audio.play(hit)
pollysHit = pollysHit + 1
score.text = pollysHit … ‘/’ … totalPollys
lastPolly.isVisible = false
end
end
function scene:enterScene( event )
local group = self.view
local hit = audio.loadSound(‘Slap.wav’)
end
function scene:exitScene( event )
local group = self.view
audio.dispose(hit)
end
function scene:destroyScene( event )
local group = self.view
display.remove(p1)
display.remove(p1)
display.remove(p3)
display.remove(p4)
display.remove(p5)
display.remove(background)
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene [import]uid: 166525 topic_id: 31800 reply_id: 331800[/import]