Multiple onComplete tasks

Hi,

Right now I have a transition.To, and onComplete it removes the object that is completing the transition.  When this happens, I would also like it to trigger another event (adding to the score).  Would it be possible to run the display.Remove of the object and add to the complete of the object?

One issue I have run into is that when making the display.Remove inside a function (which is triggered onComplete), is that all of my objects spawned are removed, which I do not want; as multiple copies of the same object are on the screen at once.  I only want objects that complete the transition to be removed, as well as add to the score.

Sorry for the confusing description, please let me know if there is any needed clarification.

Thanks

I think you’ll need to show us code in order for us to help you.  Also, keep in mind that the onComplete function is just a function like any other.  So you can do whatever you need to in that function, such as adding score or removing display objects.

Yes, you can do this:

local score = display.newText( ... your own details here ... ) -- this is just pseudo code local obj = display.newCircle( 10, 10, 10 ) obj.onComplete = function( self ) score.text = score.text + 10 display.remove( self ) end transition.to( obj, { x = 100, onComplete = obj } )

I think you’ll need to show us code in order for us to help you.  Also, keep in mind that the onComplete function is just a function like any other.  So you can do whatever you need to in that function, such as adding score or removing display objects.

Yes, you can do this:

local score = display.newText( ... your own details here ... ) -- this is just pseudo code local obj = display.newCircle( 10, 10, 10 ) obj.onComplete = function( self ) score.text = score.text + 10 display.remove( self ) end transition.to( obj, { x = 100, onComplete = obj } )