Exemplo n.º 1
0
MovableObject* SceneNode::detachObject(unsigned short index)
{
	MovableObject* ret;
	if (index < sceneObjects_.size())
	{

		ObjectMap::iterator i = sceneObjects_.begin();
		// Increment (must do this one at a time)
		while (index--)++i;

		ret = i->second;
		sceneObjects_.erase(i);
		ret->notifyAttached((SceneNode*)0);

		// Make sure bounds get updated (must go right to the top)
		notifyUpdate( BoundsChangedBit );

		return ret;

	}
	else
	{
		SML_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Object index out of bounds.");
	}
	return 0;

}
Exemplo n.º 2
0
void SceneNode::detachAllObjects(void)
{
	ObjectMap::iterator itr;
	MovableObject* ret;
	for ( itr = sceneObjects_.begin(); itr != sceneObjects_.end(); itr++ )
	{
		ret = itr->second;
		ret->notifyAttached((SceneNode*)0);
	}
	sceneObjects_.clear();
	// Make sure bounds get updated (must go right to the top)
	notifyUpdate( BoundsChangedBit );
}
Exemplo n.º 3
0
MovableObject* SceneNode::detachObject(const std::string& name)
{
	ObjectMap::iterator it = sceneObjects_.find(name);
	if (it == sceneObjects_.end())
	{
		SML_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Object " + name + " is not attached to this node.");
	}
	MovableObject* ret = it->second;
	sceneObjects_.erase(it);
	ret->notifyAttached((SceneNode*)0);
	// Make sure bounds get updated (must go right to the top)
	notifyUpdate( BoundsChangedBit );

	return ret;
}
Exemplo n.º 4
0
SceneNode::~SceneNode()
{
	removeAllChildren();

	if (parent_)
		parent_->removeChild(this);

	// Remove ourselves from the update queue
	//dequeueForUpdate(this);

	// Detach all objects, do this manually to avoid needUpdate() call
	// which can fail because of deleted items
	ObjectMap::iterator itr;
	MovableObject* ret;
	for ( itr = sceneObjects_.begin(); itr != sceneObjects_.end(); ++itr )
	{
		ret = itr->second;
		ret->notifyAttached((SceneNode*)0);
	}
	sceneObjects_.clear();
}