Help with scoring system

Hello everybody i’m new to corona and I have little question. For my game I want the score to go up by 1 everytime the ball is tapped. Now I don’t know how to code that and i’m really struggling here, and I could use all the help I can get. Thank you :slight_smile:

local score = 0 --change the ball to an image if you want using display.newImageRect(imageFile, width, height) local ball = display.newCircle(100, 100, 50) --called when the tap is initially on the ball, moved on the ball, or released on the ball function ball:touch(e) --add 1 to the score and print the score when the user touches the ball (on initial contact) if(e.phase == "began") then score = score + 1 print(score) end end --add a touch listener to the ball to allow it to receive touch events --call the method ball:touch(e) when this happens ball:addEventListener("touch", ball)

Thank you so much :slight_smile:

No problem. Glad I could help.

:slight_smile:

local score = 0 --change the ball to an image if you want using display.newImageRect(imageFile, width, height) local ball = display.newCircle(100, 100, 50) --called when the tap is initially on the ball, moved on the ball, or released on the ball function ball:touch(e) --add 1 to the score and print the score when the user touches the ball (on initial contact) if(e.phase == "began") then score = score + 1 print(score) end end --add a touch listener to the ball to allow it to receive touch events --call the method ball:touch(e) when this happens ball:addEventListener("touch", ball)

Thank you so much :slight_smile:

No problem. Glad I could help.

:slight_smile: