Summary
local function collision_champ (self, event)
local phase = event.phase;
**local id = event.target.id**
if (phase == "began") then
print( event.other.identy );
print( id );
if ( id == "champ" and event.other.identy== "drop") then
print("HEro")
else
print("not HEro")
end
end
return true
end
for i,t in pairs(decoded) do
t.name = display.newImage(sceneGroup, "img/local/champs/musketeer/musketeer.png", _W/math.random(1,8), _H/math.random(1,8));
t.name:scale( champ_view+minScale, champ_view+maxScale );
t.id = t.id;
t.name.collision = collision_champ;
t.name:addEventListener( "collision" );
t.name:addEventListener( "touch", drag_champ );
end
decoded is json:
{
“1p”:
{
“name”:“champ_shoot”,
“id”:“champ”
},
“2p”:
{
“name”:“champ_vampir”,
“id”:“champ”
},
“3p”:
{
“name”:“champ_fish”,
“id”:“champ”
},
}
why in the console?:
03:13:50.469 drop
03:13:50.469 nil
03:13:50.469 not HEro
how I can get id “champ”?