[Resolved] Display image copies on muti-button presses

I’d like a copy of the same image to appear each time the user touches a button multiple times. Not sure what to do?.

EG: Touch 7 times and seven copies of the same image comes out on screen.

Not Sure if I need to increment a loop somehow, Use a function, or both?

My head is going in circles trying to think like a programmer,but that’s normal for a newbie.

The images should be reasonably spaced out. Not all on top of each other.

I have to figure out how to deactivate the button after 7 or 10 times.

But an if then statement should do it right?

Thanks all for the help.
Jeremy [import]uid: 127028 topic_id: 27705 reply_id: 327705[/import]

This should work:

local imagesTable={}  
local numPresses=8 -- possible times you can press the button and image appears  
local xCounter=100  
  
function onBtnPress()  
if numPresses\>0 then -- only if the presses left are not 0  
numPresses=numPresses-1 -- subtract a press from total  
  
for i=#imagesTable, #imagesTable do -- create an image with the cardinality of the imagesTable as it's name  
table.insert( imagesTable, i, display.newImage( "myImage.png" ) ) -- make your image  
imagesTable[i].x=xCounter  
imagesTable[i].y=512  
end  
  
xCounter=xCounter+100 -- advance the x of the next image   
  
end  
end  
  
local myBtn=ui.newButton{ -- make your trigger button  
 default="btn.png",  
 over="btn-over.png",  
 onRelease=onBtnPress  
}  

Hope this helps!

binc [import]uid: 147322 topic_id: 27705 reply_id: 112402[/import]

Could not get ui.lua button code working at the end.
so used name:addEventListener (“tap”, onBtnPress)
and binc’s code works.

Thanks
Jeremy
[import]uid: 127028 topic_id: 27705 reply_id: 112444[/import]