hello corona community, i need help urgently, i need to update the value of one variable but i have some doubts about that.
function new
--require physics etc
--big pausegame function
--big startgame function
--and it is the importante part, my active default value is 0 but when i touch on the ball i need to change the variavel active value to 1 because of the if loop
local that = function ()
local active = 0
physics.start( true )
physics.setDrawMode( "normal" )
physics.setGravity( 0,0 )
local ball1 = display.newCircle( 80, 120, 20 )
ball1:setFillColor( 0, 255, 0 )
physics.addBody(ball1,"kinematic", { density=2, bounce=0.3, radius=25});
ball1.x = 250; ball1.y = 200
game\_objects:insert( ball1 )
local ball\_func = function()
function ball1:touch( event )
if(event.phase == "ended") then
active = active + 1
ball1.bodyType="dynamic"
physics.setGravity (0,9.8)
end
end
ball1:addEventListener( "touch", ball1 )
end
ball\_func()
if active == 0 then
pausegame()
elseif active == 1 then
startgame()
end
end
that()
return game\_objects
end
i really want to know how i can make it, because will very importante to my game and future games.
Thanks people [import]uid: 26056 topic_id: 15823 reply_id: 315823[/import]
[import]uid: 26056 topic_id: 15823 reply_id: 58472[/import]