Hello, i am trying to create a card game.
I have 3 modules, one that randomly creates the opponent and randomly presents 3 cards on the screen for the player to choose. Once the player picks a card, the game will jump to the 2nd module that will enable the opponent to play and will appear a message on the screen that the opponent is playing. Once that executes it will jump to a 3rd module that will present the player again with 3 random cards and will increase the number of rounds.
My issue is… once the game reaches the 3rd module where the player is presented again with three cards it will not execute the commands that are supposed to be executed once the player pushes on the card.
I have created a new project as a sample…The code is the following:
main.lua
local storyboard = require(“storyboard”)
local background = display.newImage(“Icon-72.png”)
storyboard.gotoScene(“level1”)
level1.lua
local storyboard = require(“storyboard”)
local level1 = storyboard.newScene()
function level1:createScene( event )
print(“level 1 create scene”)
local group = self.view
local x = 3
group:insert(display.newText(x,40,50))
– body
local card = display.newImage(“Icon-Small.png”)
card.x = 50 ; card.y = 150
group:insert(card)
function card:touch(event )
display.remove(card)
storyboard.gotoScene(“level2”)
end
card:addEventListener(“touch”,card)
end
function level1:enterScene( event )
local group = self.view
local card = display.newImage(“Icon-Small.png”)
card.x = 50 ; card.y = 150
group:insert(card)
function card:touch(event )
display.remove(card)
storyboard.gotoScene(“level2”)
end
card:addEventListener(“touch”,card)
– body
end
level1:addEventListener(“createScene”,level1)
level1:addEventListener(“enterScene”,level1)
return level1
level2.lua
local storyboard = require(“storyboard”)
local level2 = storyboard.newScene()
function level2:createScene( event )
print(“level2 create”)
local group = self.view
storyboard.purgeScene(“level1”)
storyboard.gotoScene(“level1”)
end
function level2:exitScene(event )
--storyboard.gotoScene(“level1”)
– body
end
level2:addEventListener(“createScene”,level2)
level2:addEventListener(“exitScene”,level2)
return level2
Please help