you are right I have 3 id fields, object.id = for identification, object.id3 for storing score, sorry I did not mention it earlier. :)
it’s because of the number “3”.
text=child.id3
Remove it and everything is correct.
Please check your ide to see what he says about error.
There are no errors it’s just the transition is not firing. Tried your suggestion but still the same…
you type text=child.id ?
Maybe try add parent parameter add make scorepop local variable. Also, remove it after transition completed.
local scorepop = display.newText( { parent=sceneGroup, text=child.id, x=child.x, y=child.y, fontSize=16, align="center", onComplete=display.remove } )
transition.to(scorepop, {time=500, alpha=0.0, y=(scorepop.y-100)})
Tried your code but still Transition is not firing.
The text shows up but the transition is not working or firing
Try calculating the transition target position first:
[lua]
local newY = child.y - 100
transition.to(scorepop, {time=500, alpha=0, y=newY})
[/lua]
still the same, I think the problem is that my transition.to is not firing.
even i put the code to:
transition.to(scorepop, {time=500, alpha=0})
it’s still not working
How often are you doing this loop?
are you referring to this?
- for i=sceneGroup.numChildren,1, -1 do
- local child = sceneGroup[i]
- if child.id == “s” then
- scorepop = display.newText( { text=child.id3, x=child.x, y=child.y, fontSize=16, align=“center” } )
- scorepop:setFillColor( 1,1,1 )
- transition.to(scorepop, {time=500, alpha=0, y=(child.y-100)})
- child:removeSelf()
- child = nil
- end
- end
Yes, is it a one-off or a repeated function?
a repated function
How often? Enterframe? Timer?
Try this:
for i=sceneGroup.numChildren,1, -1 do local child = sceneGroup[i] if child.id == "s" then local pop = display.newText( { text=child.id3, x=child.x, y=child.y, fontSize=16, align="center" } ) pop:setFillColor( 1,1,1 ) sceneGroup:insert(pop) local newY = child.y - 100 transition.to(pop, {time=500, alpha=0, y=newY, onComplete = function(obj) display.remove(obj) end} ) display.remove(child) child = nil end end
I’m not sure how removing display objects affect order of elements of sceneGroup “table”. So maybe try this code
local numChildren = sceneGroup.numChildren for i=numChildren,1, -1 do local child = sceneGroup[i] if child.id == "s" then local scorepop = display.newText( { parent=sceneGroup, text=child.id, x=child.x, y=child.y, fontSize=16, align="center", onComplete=display.remove } ) scorepop:setFillColor( 1,1,1 ) transition.to(scorepop, {time=500, alpha=0.0, y=(scorepop.y-100)}) end end for i=numChildren,1, -1 do local child = sceneGroup[i] if child.id == "s" then display.remove( child ) child = nil end end
What is color of your background scene? Maybe you don’t see text (transition of scorepop object) because color of text and background are similar (white)?
Should be ok as long as he iterates backwards through the table, which he is doing.
codesbyjandt why did you still writting the number “3” next to child.id ?
When I copy cut your code and try with child.id, without the “3”, it’s work.
I am sure you didn’t remove it lol.
It has nothing to do with it. It’s a perfectly valid field name. He has an .id field to identify the type and I suspect the .id3 field is used to store the score this object represents.
In his code he never mentions that id+number 3 is a non-empty value. I say it’s equal to “nil”, and the text scorepop show nothing on the screen because of it.
child.id is a string value, but not surely child.id3 (the text field of scorepop must be a string). Put tostring(child.id3), it’s surely better (and got nil !)
He never says that “id” is a non-empty value, either. We don’t have all the code, so we can only assume he has set “id3” somewhere else.
He says that his text does show up, which means it must be non-nil…
Thanks guys finally made it work.
Edited my transition tags and transition.cancel(“tags”) properly changed the sequence order of the codes.