Tutorial FXGL Game Engine - byType() Methode Reference

Michael

Administrator
Staff member
  • Thread starter
  • Admin
  • #1
Here I would love to give some examples how the byType()-method is working. This method is from the JavaFX engine
You do not have permission to view link Log in or register now.
.

byType(EntityType)
With the byType method you can get a list of entities with the given type.

You can get the first element with
Java:
var firstEntity = byType(EntityType).get(0);
You can check if there is one spawned entity from this type
Java:
byType(EntityType).isEmpty() //Returns true if the list is empty
You can run something on each entity
Java:
byType(EntityType).forEach(entity -> {
    entity.removeFromWorld(); // removes entity from world
});
Syntax
Java:
byType(EntityType)
Parameters
EntityType - Type of the entity you would like to get.
 
Top