This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:examples:objects:get_child_object_by_name [2018/05/12 12:50 (8 years ago)] – external edit 127.0.0.1 | en:examples:objects:get_child_object_by_name [2025/09/30 17:26 (6 weeks ago)] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Getting a Child Object by Name from a Parent Object ====== | ====== Getting a Child Object by Name from a Parent Object ====== | ||
| - | Starting with a parent | + | Orx provides |
| - | ===== Code ===== | + | ==== Paths ==== |
| - | < | + | Paths are composed by object names separated by '' |
| - | 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, | + | |
| - | return pstChild; | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | return orxNULL; | + | |
| - | } | + | |
| - | </ | + | |
| + | For example: | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||