Problem with getting my game to start

Im new to Corona and Im creating my first game, Im creating a whack style game I have the following lua files
build.settings
config.lua
director.lua (version 1.4)
movieclip.lua
main.lua
mainmenu.lua
loadlevel1.lua
level1.lua
loadlevel2.lua
level2.lua

the app stars fine, the main menu is fine i press play then the loading level 1 page starts then the level
1 screen appears but my pictures don’t popup can someone help me please!

my code is the following

[lua]module(…, package.seeall)

–====================================================================–
– SCENE: LEVEL 1
–====================================================================–

new = function ()

local localGroup = display.newGroup()

local background = display.newImage( “gamebackground.png” )

– OBJECTS

local p1
local p2
local p3
local p4
local p5

local pollys
local lastPolly = {}
– Load Sound

local hit = audio.loadSound(‘Slap.wav’)

– 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)

preparePollys()
end

–Prepare Pollys
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)

pollys = display.newGroup(p1, p2, p3, p4, p5)

for i = 1, pollys.numChildren do
pollys[i]:addEventListener(‘tap’, pollyHit)
pollys[i].isVisible = false
end
startTimer()
end
local startTimer = function()
timerSource = timer.performWithDelay(1400, showPolly, 0)
end

local showPolly = function(event)
if(currentPollys == totalPollys) then
director:changeScene(“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

return localGroup

end
[import]uid: 166525 topic_id: 31124 reply_id: 331124[/import]

ALSO HERE IS MY LOADLEVEL1.LUA code
[lua]module(…, package.seeall)

–====================================================================–
– SCENE: LOAD LEVEL 1
–====================================================================–

new = function ()

local localGroup = display.newGroup()

local theTimer
local loadingImage

local showLoadingScreen = function()
loadingImage = display.newImageRect( “loading.png”, 480, 320 )
loadingImage.x = 240; loadingImage.y = 160

local goToLevel = function()
director:changeScene( “level1” )
end

theTimer = timer.performWithDelay( 1000, goToLevel, 1 )
end

showLoadingScreen()

clean = function()
if theTimer then timer.cancel( theTimer ); end

if loadingImage then
–loadingImage:removeSelf()
display.remove( loadingImage )
loadingImage = nil
end
end

return localGroup

end [import]uid: 166525 topic_id: 31124 reply_id: 124482[/import]

I think you may encounter problems with the way you are declaring your functions.

Try removing the “= {}” from the forward declarations in lines 38-43, and remove the local prefixes from the actual functions themselves.

I may be completely wrong however, but it’s worth a try. [import]uid: 93133 topic_id: 31124 reply_id: 124505[/import]

Thanks for your reply but unfortunately it didn’t work here is my code after making the changes you advised.
[lua]module(…, package.seeall)

–====================================================================–
– SCENE: LEVEL 1
–====================================================================–

new = function ()

local localGroup = display.newGroup()

local background = display.newImage( “gamebackground.png” )

– OBJECTS

local p1
local p2
local p3
local p4
local p5

local pollys
local lastPolly = {}
– Load Sound

local hit = audio.loadSound(‘Slap.wav’)

– Variables

local timerSource
local currentPollys = 0
local pollysHit = 0
local totalPollys = 5

– Functions
showGameView = function(event)
score = display.newText(‘0’ … ‘/’ … totalPollys, 400, 290, native.systemFontBold, 16)
score:setTextColor(700, 700, 100)

preparePollys()
end

–Prepare Pollys
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)

pollys = display.newGroup(p1, p2, p3, p4, p5)

for i = 1, pollys.numChildren do
pollys[i]:addEventListener(‘tap’, pollyHit)
pollys[i].isVisible = false
end
startTimer()
end
startTimer = function()
timerSource = timer.performWithDelay(1400, showPolly, 0)
end

showPolly = function(event)
if(currentPollys == totalPollys) then
director:changeScene(“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

popOut = function(event)
lastPolly.yScale = lastPolly.yScale + 0.2

if(lastPolly.yScale >= 1) then
Runtime:removeEventListener(‘enterFrame’, popOut)
end
end

pollyHit = function(event)
audio.play(hit)
pollysHit = pollysHit + 1
score.text = pollysHit … ‘/’ … totalPollys
lastPolly.isVisible = false

end

return localGroup

end [import]uid: 166525 topic_id: 31124 reply_id: 124506[/import]

Hi Lemicreations,

You have to add all your images too the localGroup. If you don’t add them then they won’t appear with director.

Also, I would recommend Storyboard because it is actually a lot easier to use.

-Landon
. [import]uid: 111492 topic_id: 31124 reply_id: 124540[/import]

I’m going to sound like a real noob but unsure what you mean, thank you for replying
[text]
Hi Lemicreations,

You have to add all your images too the localGroup. If you don’t add them then they won’t appear with director.

Also, I would recommend Storyboard because it is actually a lot easier to use.

-Landon [import]uid: 166525 topic_id: 31124 reply_id: 124783[/import]

HAHA, it’s fine, I learned this way also.

All you have to do is add all your images to the localGroup.

Like below:

local bg = display.newImage(localGroup, "test.png")  
  
--OR  
  
local bg = display.newImage("test.png")  
  
localGroup:insert(bg)  

Whenever you have an image or widget, you have to add it to a group, in which your case the localGroup.

-Landon

[import]uid: 111492 topic_id: 31124 reply_id: 124800[/import]

Ok… this is officially got me. its still not working, i just want my five pictures p1, p2, p3, p4, p5 to
randomly appear one at a time on the screen and when they are tapped the next one shows up.

i tried what you said Landon, is this what you meant?

[lua]–Prepare Pollys
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.newImage(p1, p2, p3, p4, p5)
localGroup:insert(pollys)

for i = 1, pollys.numChildren do
pollys[i]:addEventListener(‘tap’, pollyHit)
pollys[i].isVisible = false
end
startTimer()
end

[import]uid: 166525 topic_id: 31124 reply_id: 124823[/import]

You forgot to add your pictures to the localGroup.

Here is what you should do:

--Prepare Pollys  
 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)  
  
 localGroup:insert(p1)  
 localGroup:insert(p2)  
 localGroup:insert(p3)  
 localGroup:insert(p4)  
 localGroup:insert(p5)  
 for i = 1, pollys.numChildren do  
 pollys[i]:addEventListener('tap', pollyHit)  
 pollys[i].isVisible = false  
 end  
 startTimer()  
 end   

Try that and tell me how it goes!

-Landon [import]uid: 111492 topic_id: 31124 reply_id: 124859[/import]

Hi Landon,

I tried exactly what you said and they still wont pop up, theres no errors in the debugger terminal, they just wont pop up.

Thanks
Emily [import]uid: 166525 topic_id: 31124 reply_id: 124863[/import]

ALSO HERE IS MY LOADLEVEL1.LUA code
[lua]module(…, package.seeall)

–====================================================================–
– SCENE: LOAD LEVEL 1
–====================================================================–

new = function ()

local localGroup = display.newGroup()

local theTimer
local loadingImage

local showLoadingScreen = function()
loadingImage = display.newImageRect( “loading.png”, 480, 320 )
loadingImage.x = 240; loadingImage.y = 160

local goToLevel = function()
director:changeScene( “level1” )
end

theTimer = timer.performWithDelay( 1000, goToLevel, 1 )
end

showLoadingScreen()

clean = function()
if theTimer then timer.cancel( theTimer ); end

if loadingImage then
–loadingImage:removeSelf()
display.remove( loadingImage )
loadingImage = nil
end
end

return localGroup

end [import]uid: 166525 topic_id: 31124 reply_id: 124482[/import]

I think you may encounter problems with the way you are declaring your functions.

Try removing the “= {}” from the forward declarations in lines 38-43, and remove the local prefixes from the actual functions themselves.

I may be completely wrong however, but it’s worth a try. [import]uid: 93133 topic_id: 31124 reply_id: 124505[/import]

Thanks for your reply but unfortunately it didn’t work here is my code after making the changes you advised.
[lua]module(…, package.seeall)

–====================================================================–
– SCENE: LEVEL 1
–====================================================================–

new = function ()

local localGroup = display.newGroup()

local background = display.newImage( “gamebackground.png” )

– OBJECTS

local p1
local p2
local p3
local p4
local p5

local pollys
local lastPolly = {}
– Load Sound

local hit = audio.loadSound(‘Slap.wav’)

– Variables

local timerSource
local currentPollys = 0
local pollysHit = 0
local totalPollys = 5

– Functions
showGameView = function(event)
score = display.newText(‘0’ … ‘/’ … totalPollys, 400, 290, native.systemFontBold, 16)
score:setTextColor(700, 700, 100)

preparePollys()
end

–Prepare Pollys
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)

pollys = display.newGroup(p1, p2, p3, p4, p5)

for i = 1, pollys.numChildren do
pollys[i]:addEventListener(‘tap’, pollyHit)
pollys[i].isVisible = false
end
startTimer()
end
startTimer = function()
timerSource = timer.performWithDelay(1400, showPolly, 0)
end

showPolly = function(event)
if(currentPollys == totalPollys) then
director:changeScene(“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

popOut = function(event)
lastPolly.yScale = lastPolly.yScale + 0.2

if(lastPolly.yScale >= 1) then
Runtime:removeEventListener(‘enterFrame’, popOut)
end
end

pollyHit = function(event)
audio.play(hit)
pollysHit = pollysHit + 1
score.text = pollysHit … ‘/’ … totalPollys
lastPolly.isVisible = false

end

return localGroup

end [import]uid: 166525 topic_id: 31124 reply_id: 124506[/import]

Hi Emily,

If you can, could you send me your whole app file so I can take a look at it? My email is ljp1203@optonline.net

Also, are you using Windows or Mac?

-Landon [import]uid: 111492 topic_id: 31124 reply_id: 124898[/import]

Hi Lemicreations,

You have to add all your images too the localGroup. If you don’t add them then they won’t appear with director.

Also, I would recommend Storyboard because it is actually a lot easier to use.

-Landon
. [import]uid: 111492 topic_id: 31124 reply_id: 124540[/import]

Hi Landon,
Im using windows, Im a little sceptical of sending my whole file, I will send just the lua files if thats ok.
I really appreciate your help Landon
Thanks
Emily [import]uid: 166525 topic_id: 31124 reply_id: 124947[/import]

Hi Emily,

Thanks again for sending me your folder to look at. After looking through all the files, I thought, in the best interest for you, I changed you from Director Class to Storyboard Class. I put all your code where it should be and it should all work now. It wasn’t giving me any errors. Also, Storyboard is a lot easier to use and it is fully supported by Corona. I also sent you the “scenetemplate.lua” file so that you can just copy and paste that whole file and work from there on later to come levels of yours. If by any chance you start getting errors, or you don’t know how to do something with Storyboard, feel free to email me the files again to look at with the errors you are getting. Or you can just put it on your post on the Corona Forums.

–Landon [import]uid: 111492 topic_id: 31124 reply_id: 124998[/import]

I’m going to sound like a real noob but unsure what you mean, thank you for replying
[text]
Hi Lemicreations,

You have to add all your images too the localGroup. If you don’t add them then they won’t appear with director.

Also, I would recommend Storyboard because it is actually a lot easier to use.

-Landon [import]uid: 166525 topic_id: 31124 reply_id: 124783[/import]

HAHA, it’s fine, I learned this way also.

All you have to do is add all your images to the localGroup.

Like below:

local bg = display.newImage(localGroup, "test.png")  
  
--OR  
  
local bg = display.newImage("test.png")  
  
localGroup:insert(bg)  

Whenever you have an image or widget, you have to add it to a group, in which your case the localGroup.

-Landon

[import]uid: 111492 topic_id: 31124 reply_id: 124800[/import]

Ok… this is officially got me. its still not working, i just want my five pictures p1, p2, p3, p4, p5 to
randomly appear one at a time on the screen and when they are tapped the next one shows up.

i tried what you said Landon, is this what you meant?

[lua]–Prepare Pollys
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.newImage(p1, p2, p3, p4, p5)
localGroup:insert(pollys)

for i = 1, pollys.numChildren do
pollys[i]:addEventListener(‘tap’, pollyHit)
pollys[i].isVisible = false
end
startTimer()
end

[import]uid: 166525 topic_id: 31124 reply_id: 124823[/import]