In my update function, after Step is the following code, but it doesn't work. And what I'm trying to do is to have a static sensor, the trashcan, where you can drag objects to delete them. But it doesn't even trace so there's something obviously wrong. And trashcan's userData is set with boxDef.userData="trashcan"; when it's created.
And another question about deleting, how would I delete all the objects with certain userData when I press a key?
Thanks for help.
Code:
if (m_world.m_contactList) {
var contact:b2Contact=m_world.m_contactList;
if (contact.GetShape1().GetBody().GetUserData()=="trashcan") {
trace("Deleted.");
var deletedbody=contact.GetShape2().GetBody();
m_world.DestroyBody(deletedbody);
}
}
var contact:b2Contact=m_world.m_contactList;
if (contact.GetShape1().GetBody().GetUserData()=="trashcan") {
trace("Deleted.");
var deletedbody=contact.GetShape2().GetBody();
m_world.DestroyBody(deletedbody);
}
}
And another question about deleting, how would I delete all the objects with certain userData when I press a key?
Thanks for help.