One Button, Multiple touch events

I have 5 pictures on top of one another, I have one button, where I want it to remove one image every time the button is touched. I have no idea how to go about this. many thanks for any help. [import]uid: 14967 topic_id: 17973 reply_id: 317973[/import]

Are these images inside a group?
Then you could just loop through the groupchildren :slight_smile:

i.e.:

[code]
– Create Images
local imageA = display.newImage(“ImageA.png”)
– etc

– Create Group
local imageGroup = display.newGroup()

– Insert Into Group (every image)
imageGroup:insert(imageA)

local function removeImage(event)
– using imageGroup.numChildren, we get the number of images inside the group and the last element
– we could also delete random images using math.random(1,imageGroup.numChildren)
if (imageGroup.numChildren > 0) then
imageGroup[imageGroup.numChildren]:removeSelf()
end
end

Runtime:addEventListener(“tap”,removeImage)
[/code] [import]uid: 13097 topic_id: 17973 reply_id: 68632[/import]

Thank you very much!!! It is working perfectly!!! [import]uid: 14967 topic_id: 17973 reply_id: 68634[/import]

is there a way to assign tap counts to different events?

like if I tap once it will remove an image
and if I tap again on the same button it was start an animation?

Thanks [import]uid: 14967 topic_id: 17973 reply_id: 69221[/import]

I know am doing this code wrong, cause I am getting an error, any help?

local function removeImages( event )  
 if event.phase == "ended" then  
 layer6:removeSelf()  
 later6 = nil  
 end  
 if layer6 == nil then  
 layer5:removeSelf()  
 end  
end  
  
shovel:addEventListener( "touch", removeImages )  

I have 6 images that I want to put in to this function. if layer 6 is removed already when the function is called I want it to remove layer 5 instead and so on till I get to the last image

is it possible to do that? [import]uid: 14967 topic_id: 17973 reply_id: 69233[/import]