Skip to content

Commit

Permalink
Merge pull request #295 from fadam87/optimalization
Browse files Browse the repository at this point in the history
Optimalization
  • Loading branch information
JamesTKhan authored Nov 22, 2024
2 parents 3a7f97b + 50302b8 commit d4e8cea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,19 @@ public Array<GameObject> findChildrenByName(String name) {
* @return Array of all matching GameObjects
*/
public Array<GameObject> findChildrenByComponent(Component.Type type) {
Array<GameObject> objects = new Array<>();

return findChildrenByComponent(type, new Array<GameObject>());
}

/**
* Returns an Array of all child GameObjects that have the given Component.Type
*
* @param type the Component Type to search for
* @param objects an Array to collect matching GameObjects (uploading array)
* @return Array of all matching GameObjects
*/
public Array<GameObject> findChildrenByComponent(Component.Type type, Array<GameObject> objects) {

for (GameObject go : this) {
Component component = go.findComponentByType(type);
if (component != null) {
Expand All @@ -284,7 +296,19 @@ public Array<GameObject> findChildrenByComponent(Component.Type type) {
* @return Array of all matching GameObjects
*/
public Array<GameObject> findChildrenByTag(String tag) {
Array<GameObject> objects = new Array<>();

return findChildrenByTag(tag, new Array<GameObject>());
}

/**
* Returns an Array of all child GameObjects that have the given Tag
*
* @param tag the string tag to search for
* @param objects an Array to collect matching GameObjects (uploading array)
* @return Array of all matching GameObjects
*/
public Array<GameObject> findChildrenByTag(String tag, Array<GameObject> objects) {

for (GameObject go : this) {
if (go.tags != null && go.tags.contains(tag, false)) {
objects.add(go);
Expand Down
1 change: 1 addition & 0 deletions gdx-runtime/CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Generic findComponentsByType and findComponentByType methods
- Fix render water if it is child game object
- Update gdx-gltf version to 2.2.1
- Add findChildrenByComponent(Component.Type, Array<GameObject>) and findChildrenByTag(String, Array<GameObject>) methods into GameObject file
- Set source compatibility to 1.8

[0.5.1] ~ 08/08/2023
Expand Down

0 comments on commit d4e8cea

Please sign in to comment.