Error in game

Hi , 

Being a Newbie - I am developing a simple game with normal tap functions & character movements. However I am encountering the following problems. 

Problem - 

  1. After some time the questions overlap - in ideal condition, the overlap should not happen - the next question should appear only after the correct character has been tapped. Some times it starts immediately & sometimes - only after few taps have happened.

  2. The speed of the characters - increases or decreases on its own. I am unable to regulate it.

  3. The right answer sound is not functioning. It functions well in the simulator - but does not work on the device.

  4. All the above problems were not occurring, untill the time - I had only 1 scene. As soon as I had more than 1 scene - this started happening. (However, there is no impact scene transition).  

Other info - I am using composer()  - no problems there.

The code is as follows: 

local function game()

– variable to select random no.

i = math.random(#test)

print ( i )

j = math.random(#test)

print (j)

k = math.random(#test)

print (k)

–if j == i then j = math.random(#test)

–if j == k then k = math.random(#test)

–i ~= j ~= k

–l = math.random(#test)

–print (l)

–option1

a = test[i]

local text = display.newImage(a)

text.x = math.random(0, display.contentWidth)

text.y = math.random (0, display.contentHeight)

–option 2 - 

b = test[j]

local text1 = display.newImage( B) --, 150, 160, native.systemFont, 26)

text1.x = math.random(0, display.contentWidth)

text1.y = math.random (0, display.contentHeight)

– option 3

c = test[k]

local text2 = display.newImage© --, 200, 160, native.systemFont, 26)

text2.x = math.random(0, display.contentWidth)

text2.y = math.random (0, display.contentHeight)

–main Question

local mainText = display.newImage(b,_W/2,_H/2) --, 160, 70, native.systemFont, 72)

sceneGroup:insert(text)

sceneGroup:insert(text1)

sceneGroup:insert(text2)

sceneGroup:insert(mainText)

–Random movement of Text, needs to be called separate - see below how it is being called. 

local function moveText()

transition.to(text, {time= 7000, x= math.random(0,_W), y = math.random(0,_H), onComplete = moveText})

transition.to(text1, {time= 7000, x= math.random(0,_W), y = math.random(0,_H) })

transition.to(text2, {time= 7000, x= math.random(0,_W), y = math.random(0,_H)})

–onComplete works even if it is called only once.

end

– onTap function for correct answer

local function onTap(event)

if event.phase == “ended” then

text:removeSelf()

text1:removeSelf()

text2:removeSelf()

mainText:removeSelf()

local t = display.newText(“Well Done”, event.x, event.y, native.systemFont, 26)

playSound(“right”)

transition.to(t, {alpha = 0, time = 2000, onComplete= game})

end

end

– onTap function for other answers

local function onTap1(event)

if event.phase == “ended” then

local t = display.newText(“Try Again”, event.x, event.y, native.systemFont, 26)

playSound(“wrong”)

transition.to(t, {alpha = 0, time = 2000, onComplete = game})

end

end

–function to handle exit button

local function exitBtnPressed(event)

       – playSound(“select”)

        composer.gotoScene(“scene7”, {effect = “fade”, time = 100})

        return true

    end

    --exit button symbol

local exitBtn = display.newText(“X”,0,0,native.systemFont, 26)  --display.newImage(“images/home.png”)   

    exitBtn.x = xMin+40; exitBtn.y = yMin+40

exitBtn:addEventListener(“tap”, exitBtnPressed)

sceneGroup:insert(exitBtn)

– calling function which is not event based. 

moveText()

text1:addEventListener(“touch”, onTap)

text:addEventListener(“touch”, onTap1)

text2:addEventListener(“touch”, onTap1)

end

game()

Please help. 

Also - where can I learn about debugging. 

Thanks in advance.

Here’s a useful resource for debugging: http://docs.coronalabs.com/guide/basics/debugging/index.html

Thanks _memo . Appreciate it. 

@All - would be great, if you can tell - what is the problem with my code & how I can fix it.  Thanks. :slight_smile:

Hi  All

My problem is still unresolved. I thought that there is a problem in the onTap function. But I saw the following error in the console.

WARNING: Cannot create path for resource file ‘scene4.ccscene’. File does not exist.

This is a old code -  i have been working on since a long time - because I was not so regular. Now that I am about to complete the project, I am having this issue.

I read somewhere that old code in previous versions can be an issue - but unable to find the article.

Please help.  

Hi @BTS,

Well, the error message indicates that there should be (or once was) a “scene4” file that you built in the Composer GUI, but now it can’t find that file. Are you still using the Composer GUI or did you switch over to more manual Lua-based development of the game?

Take care,

Brent

Hi Brent, 
 
 The problem - WARNING: Cannot create path for resource file ‘scene4.ccscene’. File does not exist. 
 
got resolved - thanks for pointing out. However - the objects object overlap problem still exists. 
 
Here is the Problem - 
 

  1. After some time the questions overlap - in ideal condition, the overlap should not happen - the next question should appear only after the correct character has been tapped. Sometimes it starts immediately & sometimes - only after few taps have happened.
     
    & the screenshot for the same is in the attachment. 

In the image - a & i are overlapping - they are actually the question image - “i” should not have come - untill the time “a” disappears from the screen. But that is not happening. When enter the scene - sometimes - this problems happens from the very begining & sometimes after some delay.

don’t know how to solve it.  

code for the same is in OP

Here’s a useful resource for debugging: http://docs.coronalabs.com/guide/basics/debugging/index.html

Thanks _memo . Appreciate it. 

@All - would be great, if you can tell - what is the problem with my code & how I can fix it.  Thanks. :slight_smile:

Hi  All

My problem is still unresolved. I thought that there is a problem in the onTap function. But I saw the following error in the console.

WARNING: Cannot create path for resource file ‘scene4.ccscene’. File does not exist.

This is a old code -  i have been working on since a long time - because I was not so regular. Now that I am about to complete the project, I am having this issue.

I read somewhere that old code in previous versions can be an issue - but unable to find the article.

Please help.  

Hi @BTS,

Well, the error message indicates that there should be (or once was) a “scene4” file that you built in the Composer GUI, but now it can’t find that file. Are you still using the Composer GUI or did you switch over to more manual Lua-based development of the game?

Take care,

Brent

Hi Brent, 
 
 The problem - WARNING: Cannot create path for resource file ‘scene4.ccscene’. File does not exist. 
 
got resolved - thanks for pointing out. However - the objects object overlap problem still exists. 
 
Here is the Problem - 
 

  1. After some time the questions overlap - in ideal condition, the overlap should not happen - the next question should appear only after the correct character has been tapped. Sometimes it starts immediately & sometimes - only after few taps have happened.
     
    & the screenshot for the same is in the attachment. 

In the image - a & i are overlapping - they are actually the question image - “i” should not have come - untill the time “a” disappears from the screen. But that is not happening. When enter the scene - sometimes - this problems happens from the very begining & sometimes after some delay.

don’t know how to solve it.  

code for the same is in OP