What I’m trying to do is create a method that allows a user to search through a list of GameComponents to find a GameComponent of whatever class they passed in.
I’m at a total loss on how to do this. Any Ideas?
This is what I’ve tried so far. I’ve tried a lot of different ways to do it but I keep getting classDude cannot be resolved to a type. Thanks in advance.
public GameComponent<?> getComponentOfType(Class<Object> classDude)
{
for(GameComponent<?> gC : mComponentList)
{
if(gC instanceof classDude)
{
}
}
}
It sounds like you want:
Or without making it generic:
In other words, what you were missing were the
Class.isInstanceandClass.castmethods.