well, here is the code I use:
–object 1 (o1)
physics.addBody( o1, “dynamic”, physicsData:get(“o1shape”) )
o1.hit = “o1Hit”
o1:addEventListener( “collision”, o1 )
–analog for o2, then:
function o1:collision ( event )
if event.other.hit == “o2” then
o1:removeSelf()
end
that works now. what did not work was:
–snip
o1.hit = o1Hit
–snip
function o1Hit ( event )
or
Runtime:addEventListener( “collision”, o1 )
when I had the removal of o1 in:
function o2:collision ( event )
if event.other.hit == “o1” then
o1:removeSelf()
end
removal did not work when I was spawning more than 1 o1, i.e. had o1 generation embedded inside a function.
also, now I want to do:
function o1:collision ( event )
if event.other.hit == “o2” then
spriteInstanceO1.x = o3.x
spriteInstanceO1.y = o3.y
spriteInstanceO1(play)
o1:removeSelf()
end
I get an error saying that I was trying to index a global variable spriteInstanceO1 and o3 which is nil.
All those objects are declared as local.
It would really help me with insight into what is going wrong, why sometimes function do not see the objects and sometimes (especially in all the real code others write:) ) they do.
[import]uid: 109677 topic_id: 21700 reply_id: 86286[/import]