how to: if the player touched anywhere but the buttons on the screen in a specific arrangement, he will lose a life. - Corona sdk

down votefavorite
 

I am trying to make a game using corona SDK.

The game is about 3 buttons, the player needs to press them in a specific arrangement (1==>2==>3). and if the player touched anywhere but the buttons in that arrangement, he will lose a life.

my problem is in the 2nd part. how can i do that. any suggestions please.

Thnx in advance.

First of all, it would be better for you if you ask those kind of questions in Newbie Questions part of the forum.

For your question, you can set a listener to your background image and when he clicks something other than those buttons he will lose life.

For the arrangement part, that might be the answer to your problem -> http://gamedevnation.com/game-development/create-a-simon-game-in-corona-sdk/

Thnx for your reply. I did what u advised me, but my problem is on circle no. 3 whenever i touch it there i will get both “You Win” and “You Lose”.

this is my code:

 in the below code i created 7 circles and the player needs to choose the green one each time.

–circle 1 tapped

local function c1Tapped(event)

circle1.isVisible = false

circle2.isVisible = true

circle4.isVisible = true

return true

end

local function c2Tapped(event)

circle1.isVisible = false

circle2.isVisible = false

circle4.isVisible = false

circle3.isVisible = true

circle5.isVisible = true

circle6.isVisible = true

circle7.isVisible = true

return true

end

local function c3Tapped(event)

win.isVisible = true

nextLevel.isVisible = true

home.isVisible = true

winBox.isVisible = true

circle3.isVisible = false

circle5.isVisible = false

circle6.isVisible = false

circle7.isVisible = false

end

function backgroundTouched (event)

print(“You Lose”)

end

circle1:addEventListener ( “tap”, c1Tapped )—Circle3 Event Listner

circle2:addEventListener ( “tap”, c2Tapped )—Circle3 Event Listner

circle3:addEventListener( “tap”, c3Tapped )  —Circle3 Event Listner

home:addEventListener ( “tap”, winTapped ) — quit game event listner

nextLevel:addEventListener( “tap”, winTapped ) — next level button event Listner

background:addEventListener( “tap”, backgroundTouched ) —Background event Listner

Have you looked at the Simon Game example? It will probably solve all your problems.

By the way, it would be better if you paste your code using “<>” button. It’s hard to read it this way.

You haven’t posted all relevant parts of your code but it seems that you are making the _ win _ visible which might be the problem.

thnx alot SIR.

I will read Simon’s code tonight. if i have any doubt it post here again 

First of all, it would be better for you if you ask those kind of questions in Newbie Questions part of the forum.

For your question, you can set a listener to your background image and when he clicks something other than those buttons he will lose life.

For the arrangement part, that might be the answer to your problem -> http://gamedevnation.com/game-development/create-a-simon-game-in-corona-sdk/

Thnx for your reply. I did what u advised me, but my problem is on circle no. 3 whenever i touch it there i will get both “You Win” and “You Lose”.

this is my code:

 in the below code i created 7 circles and the player needs to choose the green one each time.

–circle 1 tapped

local function c1Tapped(event)

circle1.isVisible = false

circle2.isVisible = true

circle4.isVisible = true

return true

end

local function c2Tapped(event)

circle1.isVisible = false

circle2.isVisible = false

circle4.isVisible = false

circle3.isVisible = true

circle5.isVisible = true

circle6.isVisible = true

circle7.isVisible = true

return true

end

local function c3Tapped(event)

win.isVisible = true

nextLevel.isVisible = true

home.isVisible = true

winBox.isVisible = true

circle3.isVisible = false

circle5.isVisible = false

circle6.isVisible = false

circle7.isVisible = false

end

function backgroundTouched (event)

print(“You Lose”)

end

circle1:addEventListener ( “tap”, c1Tapped )—Circle3 Event Listner

circle2:addEventListener ( “tap”, c2Tapped )—Circle3 Event Listner

circle3:addEventListener( “tap”, c3Tapped )  —Circle3 Event Listner

home:addEventListener ( “tap”, winTapped ) — quit game event listner

nextLevel:addEventListener( “tap”, winTapped ) — next level button event Listner

background:addEventListener( “tap”, backgroundTouched ) —Background event Listner

Have you looked at the Simon Game example? It will probably solve all your problems.

By the way, it would be better if you paste your code using “<>” button. It’s hard to read it this way.

You haven’t posted all relevant parts of your code but it seems that you are making the _ win _ visible which might be the problem.

thnx alot SIR.

I will read Simon’s code tonight. if i have any doubt it post here again