I am trying to get different things to happen on different numbered touches ( if that makes any sense ) so if I touch the button once it will remove an image, and if I touch it again ( second time ) it would call a function. I’ve been trying different ways but after the image is removed I keep getting an error, that the image is nil, cause it is already removed. Thanks [import]uid: 14967 topic_id: 18317 reply_id: 318317[/import]
Posting some code would help. It’s hard from your description to figure out what you are trying to accomplish.
-David [import]uid: 96411 topic_id: 18317 reply_id: 70201[/import]
I am creating a dinosaur game for kids. In one section of the app, they can dig up dinosaur bones. I have 6 pictures all with different alpha masks to expose more bones as you dig. I have a shovel button with a removeSelf event for the images every time the button is tapped until it gets to the last image then it wont remove anymore images ( xxxfanta help me with that one )
--
local function removeImage( event )
if ( digGroup.numChildren \> 1 ) then
digGroup[digGroup.numChildren]:removeSelf()
end
end
shovel:addEventListener( "tap", removeImage )
my question is can you create a function and/or button ( I’m guessing ) that when it is touched once it will remove the first layer, then touched again to remove the second layer etc. etc. till you get to the end which would be 6 touches then on the 7th touch of the button it would bring you to a new scene or call a transition to start?
i dont know how the code would go, but this is to get an idea
if touch1 then
layer1:removeSelf()
if touch2 then
layer2:removeSelf()
if touch7 then
director:changeScene( "dinoBuild" )
right now anything that I try to do, gives me an error, because if the images are removed already I get a nil error
I tried this with no luck
--
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 )
Thanks [import]uid: 14967 topic_id: 18317 reply_id: 70208[/import]
I would consider not deleting the object, but rather have the object displayed as a sprite that is indexed with each scoop of a shovel. You could had the image represented as 2.5D image.
Might be easier and address an issue if the player only digs part way and moves on to another location.
-David
[import]uid: 96411 topic_id: 18317 reply_id: 70230[/import]