Hi
I’m very new to Lua and Corona (about 1 week old)
I’m trying to make a simple game that starts by displaying one screen wide image with a a square shape object hidden in the image. if the player clicks (or taps) the object the original image is replaced with a second one and the object is also replaced with a second square object hidden in the second image.
The players gets points if they click/tap the object and lose points if they click on the image.
In some levels i’d like to add a second negative image (one that takes away a larger amount of points if clicked).
My problem is that once the object is clicked and the new image and square object load the first square object is still active under the new image. as the game progresses there are far too many squares still active under the newer image. That and I have now way to set up the scores. (I’d like the final score to be displayed only at the end of the game.
here is an example of the code: (I have 12 images in total so this repeats over and over)
function createPlayScreen()
local image = display.newImageRect(“Slide001.png”, display.contentWidth, display.contentHeight)
image.anchorX = 0
image.anchorY = 0
local rectangleA = display.newRect( 110, 290, 100, 100 )
rectangleA.alpha = 1
rectangleA:addEventListener ( “tap”, slide1, score + 1, shipSmash, {onComplete = removeRect }, onTouch, rectangleA:toBack( ),{removeObjectOntouch} ) --rectangle:removeSelf();
–rectangle = nil
end
function slide1()
local image1 = display.newImageRect(“Slide002.png”, display.contentWidth, display.contentHeight)
image1.anchorX = 0
image1.anchorY = 0
image1.alpha = 1
local rectangle1 = display.newRect( 720, 312, 100, 110 )
rectangle1.alpha = .1
rectangle1:toFront( )
rectangle1:addEventListener ( “tap”, slide3, onTouch,rectangle1:toBack( ), {removeObjectOntouch} )
end
function slide2()
local image2 = display.newImageRect(“Slide003.png”, display.contentWidth, display.contentHeight)
image2.anchorX = 0
image2.anchorY = 0
image2.alpha = 1
local rectangle2 = display.newRect( 720, 312, 100, 110 )
rectangle2.alpha = 1
rectangle2:toFront( )
rectangle2:addEventListener ( “tap”, slide3, onTouch, rectangle2:toBack( ), {removeObjectOntouch} )
end
As you can see I’m trying to have the original objects be removed or go to the back and add a score, but no luck.
Thanks in advance.