I’m making a game, when I start the first level of the game all functions work well, but when the game is over and I back to the main menu and star the same level all functions go crazy … the function timer goes two by two and the function drag don’t respond . My question is … There are some start up code to the functions as the first time you load? [import]uid: 180288 topic_id: 36703 reply_id: 336703[/import]
2 by 2?? Definite cause is that your timer is running 2 times. Had the same problem.
Make sure you stop all timers when you leave the game screen. [import]uid: 114363 topic_id: 36703 reply_id: 145005[/import]
my times running in pairs instead of one ( 2,4,6,…) instead ( 1,2,3,…)
when the game is over I use timer.cancel(timerGame)
is any other code ? [import]uid: 180288 topic_id: 36703 reply_id: 145007[/import]
Can you post some code? [import]uid: 114363 topic_id: 36703 reply_id: 145013[/import]
local function getNum()
if cant ~= 3 then
temp1 = math.random(0, 9)
else
timer.cancel(reloj)
grupo.alpha = 0
grupoAlerta.alpha = 1
grupoAlerta.x = 5
grupoAlerta.y = alto + grupoAlerta.height
transition.to(grupoAlerta, {time = 300, y = 0})
cant = 0
secsText = 0
minsText = 0
mensaje.text = " "
mensajeConteo.text = " "
timeText.text = “00:00”
end
return true
end
local function drag( event )
local ball = event.target
local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( ball )
–Save de initial position
inicioX = event.target.x
inicioY = event.target.y
– Store initial position
ball.x0 = event.x - ball.x
ball.y0 = event.y - ball.y
event.target.bodyType = “kinematic”
else
if “moved” == phase then
ball.x = event.x - ball.x0
ball.y = event.y - ball.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
event.target.bodyType = “dynamic”
if posicion == “ninguno” then
pos1 = event.target.name
ball.x = 70
ball.y = alto/2 - 100
posicion = “primer”
elseif posicion == “primer” then
pos2 = event.target.name
ball.x = 130
ball.y = alto/2 - 100
posicion = “segundo”
elseif posicion == “segundo” then
ball.x = inicioX
ball.y = inicioY
end
end
end
return true
end
function starGame()
reloj = timer.performWithDelay(1000, updateTime, 0)
getNum()
openFile()
uno:addEventListener(“touch”,drag)
dos:addEventListener(“touch”,drag)
tres:addEventListener(“touch”,drag)
end
[import]uid: 180288 topic_id: 36703 reply_id: 145117[/import]
2 by 2?? Definite cause is that your timer is running 2 times. Had the same problem.
Make sure you stop all timers when you leave the game screen. [import]uid: 114363 topic_id: 36703 reply_id: 145005[/import]
my times running in pairs instead of one ( 2,4,6,…) instead ( 1,2,3,…)
when the game is over I use timer.cancel(timerGame)
is any other code ? [import]uid: 180288 topic_id: 36703 reply_id: 145007[/import]
Can you post some code? [import]uid: 114363 topic_id: 36703 reply_id: 145013[/import]
local function getNum()
if cant ~= 3 then
temp1 = math.random(0, 9)
else
timer.cancel(reloj)
grupo.alpha = 0
grupoAlerta.alpha = 1
grupoAlerta.x = 5
grupoAlerta.y = alto + grupoAlerta.height
transition.to(grupoAlerta, {time = 300, y = 0})
cant = 0
secsText = 0
minsText = 0
mensaje.text = " "
mensajeConteo.text = " "
timeText.text = “00:00”
end
return true
end
local function drag( event )
local ball = event.target
local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( ball )
–Save de initial position
inicioX = event.target.x
inicioY = event.target.y
– Store initial position
ball.x0 = event.x - ball.x
ball.y0 = event.y - ball.y
event.target.bodyType = “kinematic”
else
if “moved” == phase then
ball.x = event.x - ball.x0
ball.y = event.y - ball.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
event.target.bodyType = “dynamic”
if posicion == “ninguno” then
pos1 = event.target.name
ball.x = 70
ball.y = alto/2 - 100
posicion = “primer”
elseif posicion == “primer” then
pos2 = event.target.name
ball.x = 130
ball.y = alto/2 - 100
posicion = “segundo”
elseif posicion == “segundo” then
ball.x = inicioX
ball.y = inicioY
end
end
end
return true
end
function starGame()
reloj = timer.performWithDelay(1000, updateTime, 0)
getNum()
openFile()
uno:addEventListener(“touch”,drag)
dos:addEventListener(“touch”,drag)
tres:addEventListener(“touch”,drag)
end
[import]uid: 180288 topic_id: 36703 reply_id: 145117[/import]
2 by 2?? Definite cause is that your timer is running 2 times. Had the same problem.
Make sure you stop all timers when you leave the game screen. [import]uid: 114363 topic_id: 36703 reply_id: 145005[/import]
my times running in pairs instead of one ( 2,4,6,…) instead ( 1,2,3,…)
when the game is over I use timer.cancel(timerGame)
is any other code ? [import]uid: 180288 topic_id: 36703 reply_id: 145007[/import]
Can you post some code? [import]uid: 114363 topic_id: 36703 reply_id: 145013[/import]
local function getNum()
if cant ~= 3 then
temp1 = math.random(0, 9)
else
timer.cancel(reloj)
grupo.alpha = 0
grupoAlerta.alpha = 1
grupoAlerta.x = 5
grupoAlerta.y = alto + grupoAlerta.height
transition.to(grupoAlerta, {time = 300, y = 0})
cant = 0
secsText = 0
minsText = 0
mensaje.text = " "
mensajeConteo.text = " "
timeText.text = “00:00”
end
return true
end
local function drag( event )
local ball = event.target
local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( ball )
–Save de initial position
inicioX = event.target.x
inicioY = event.target.y
– Store initial position
ball.x0 = event.x - ball.x
ball.y0 = event.y - ball.y
event.target.bodyType = “kinematic”
else
if “moved” == phase then
ball.x = event.x - ball.x0
ball.y = event.y - ball.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
event.target.bodyType = “dynamic”
if posicion == “ninguno” then
pos1 = event.target.name
ball.x = 70
ball.y = alto/2 - 100
posicion = “primer”
elseif posicion == “primer” then
pos2 = event.target.name
ball.x = 130
ball.y = alto/2 - 100
posicion = “segundo”
elseif posicion == “segundo” then
ball.x = inicioX
ball.y = inicioY
end
end
end
return true
end
function starGame()
reloj = timer.performWithDelay(1000, updateTime, 0)
getNum()
openFile()
uno:addEventListener(“touch”,drag)
dos:addEventListener(“touch”,drag)
tres:addEventListener(“touch”,drag)
end
[import]uid: 180288 topic_id: 36703 reply_id: 145117[/import]
2 by 2?? Definite cause is that your timer is running 2 times. Had the same problem.
Make sure you stop all timers when you leave the game screen. [import]uid: 114363 topic_id: 36703 reply_id: 145005[/import]
my times running in pairs instead of one ( 2,4,6,…) instead ( 1,2,3,…)
when the game is over I use timer.cancel(timerGame)
is any other code ? [import]uid: 180288 topic_id: 36703 reply_id: 145007[/import]
Can you post some code? [import]uid: 114363 topic_id: 36703 reply_id: 145013[/import]
local function getNum()
if cant ~= 3 then
temp1 = math.random(0, 9)
else
timer.cancel(reloj)
grupo.alpha = 0
grupoAlerta.alpha = 1
grupoAlerta.x = 5
grupoAlerta.y = alto + grupoAlerta.height
transition.to(grupoAlerta, {time = 300, y = 0})
cant = 0
secsText = 0
minsText = 0
mensaje.text = " "
mensajeConteo.text = " "
timeText.text = “00:00”
end
return true
end
local function drag( event )
local ball = event.target
local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( ball )
–Save de initial position
inicioX = event.target.x
inicioY = event.target.y
– Store initial position
ball.x0 = event.x - ball.x
ball.y0 = event.y - ball.y
event.target.bodyType = “kinematic”
else
if “moved” == phase then
ball.x = event.x - ball.x0
ball.y = event.y - ball.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
event.target.bodyType = “dynamic”
if posicion == “ninguno” then
pos1 = event.target.name
ball.x = 70
ball.y = alto/2 - 100
posicion = “primer”
elseif posicion == “primer” then
pos2 = event.target.name
ball.x = 130
ball.y = alto/2 - 100
posicion = “segundo”
elseif posicion == “segundo” then
ball.x = inicioX
ball.y = inicioY
end
end
end
return true
end
function starGame()
reloj = timer.performWithDelay(1000, updateTime, 0)
getNum()
openFile()
uno:addEventListener(“touch”,drag)
dos:addEventListener(“touch”,drag)
tres:addEventListener(“touch”,drag)
end
[import]uid: 180288 topic_id: 36703 reply_id: 145117[/import]