Hello guys,
I’m a newbie to corona sdk trying to create a android game app ,i need some help from you guys
I’m trying to create a small game app where i need to toggle between images on touch
for e.g i have two images image1.png,image2.png
Both the images are displayed in the same position alternatively.
When game starts only image1.png will be displayed and image2.png will be invisible.
Image2.png will be displayed when image1.png is clicked, once this click happens … image2.png is displayed and image1.png will become invisible.
This cycle continues, its like a toggle effect where a user can toggle between two images for ‘n’ number of times
i’m struck at a phase where when i can display both the images only for the 1st time but I’m unable to display it for the next time…Dont know how to code further…i’m very new to corona sdk so please help me by altering my code or sending a new code or any reference links
Here is my lua code
object = display.newImage( "dice.png",150,150 ) object.xScale = 1 object.yScale = 1 object.id = "dice1" object.isVisible = true function object:touch( event ) if event.phase == "began" then print "Dice one rolled on " object.isVisible = false objectt = display.newImage( "dice2.png",345,150 ) objectt.xScale = 1 objectt.yScale = 1 function objectt:touch( event ) if event.phase == "began" then objectt.isVisible = false objectt = display.newImage("dice.png",150,150) objectt.xScale = 1 objectt.yScale = 1 print "Dice two rolled on " end return true end objectt:addEventListener( "touch", objectt ) end return true end object:addEventListener( "touch", object )
Waiting for quick reply
Regards
saideep