Skip to content

Commit 08e3cb0

Browse files
committed
get child generic
1 parent 0fbc560 commit 08e3cb0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/com/javagamemaker/javagameengine/components/Component.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,15 @@ public LinkedList<Component> getAllChildren(Component type){
462462
return children;
463463
}
464464

465+
public <T>T getChild(){
466+
for (Component child : this.children){
467+
try{
468+
return ((T)child);
469+
}
470+
catch (Exception e){}
471+
}
472+
return null;
473+
}
465474
/**
466475
* @param type the specified type of the children to be returned
467476
* @return if type is (new PhysicsBody()) it will return the first child that is a physicsBody as Component

0 commit comments

Comments
 (0)