User Tools

Site Tools


en:examples:objects:get_child_object_by_name

Getting a Child Object by Name from a Parent Object

Starting with a parent object, get the first Child Object by name.

Code

orxOBJECT* GetChildObjectByName(orxOBJECT *parentObject, orxSTRING childName) {
	for (orxOBJECT *pstChild = orxObject_GetOwnedChild(parentObject);
		pstChild;
		pstChild = orxObject_GetOwnedSibling(pstChild))
		{
			const orxSTRING name = orxObject_GetName(pstChild);
			if (orxString_Compare(name, childName) == 0) {
				return pstChild;
			}
		}
 
	return orxNULL;
}

en/examples/objects/get_child_object_by_name.txt · Last modified: 2018/05/12 12:50 (2 years ago) (external edit)