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.
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
One Button, Multiple touch events
Are these images inside a group?
Then you could just loop through the groupchildren :)
i.e.:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | -- 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) |
Thank you very much!!! It is working perfectly!!!
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
I know am doing this code wrong, cause I am getting an error, any help?
1 2 3 4 5 6 7 8 9 10 11 | 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 ) |
views:1526 update:2011/11/25 8:45:21
热门文章
GameCenter LeaderBoards and Achievements Enabled Through OpenFeint
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
相关文章
Help with physic bodies [SOLVED]
Physics object set velocity but not moving
Promo Code Swap?
Clownfish not working
Need a subscriber to test something
Doodle Sheep
Preventing a physics body from tumbling
Display object losing the addEventListener function
Keyboard Question
TIP: Getting YOUR Web Presence Online Fast
Physics object set velocity but not moving
Promo Code Swap?
Clownfish not working
Need a subscriber to test something
Doodle Sheep
Preventing a physics body from tumbling
Display object losing the addEventListener function
Keyboard Question
TIP: Getting YOUR Web Presence Online Fast
corona forums © 2003-2011