diff --git a/ashley/src/com/badlogic/ashley/core/Engine.java b/ashley/src/com/badlogic/ashley/core/Engine.java index c195706e..5ef14efb 100644 --- a/ashley/src/com/badlogic/ashley/core/Engine.java +++ b/ashley/src/com/badlogic/ashley/core/Engine.java @@ -50,6 +50,14 @@ public class Engine { private FamilyManager familyManager = new FamilyManager(entityManager.getEntities()); private boolean updating; + /** + * Creates a new Entity object. + * @return @{@link Entity} + */ + + public Entity createEntity () { + return new Entity(); + } /** * Adds an entity to this Engine. diff --git a/ashley/src/com/badlogic/ashley/core/PooledEngine.java b/ashley/src/com/badlogic/ashley/core/PooledEngine.java index ada691f0..688f66cd 100644 --- a/ashley/src/com/badlogic/ashley/core/PooledEngine.java +++ b/ashley/src/com/badlogic/ashley/core/PooledEngine.java @@ -60,7 +60,8 @@ public PooledEngine (int entityPoolInitialSize, int entityPoolMaxSize, int compo componentPools = new ComponentPools(componentPoolInitialSize, componentPoolMaxSize); } - /** @return Clean {@link Entity} from the Engine pool. In order to add it to the {@link Engine}, use {@link #addEntity(Entity)}. */ + /** @return Clean {@link Entity} from the Engine pool. In order to add it to the {@link Engine}, use {@link #addEntity(Entity)}. @{@link Override {@link Engine#createEntity()}} */ + @Override public Entity createEntity () { return entityPool.obtain(); } diff --git a/ashley/tests/com/badlogic/ashley/core/EngineTests.java b/ashley/tests/com/badlogic/ashley/core/EngineTests.java index e0a24f22..b2b86468 100644 --- a/ashley/tests/com/badlogic/ashley/core/EngineTests.java +++ b/ashley/tests/com/badlogic/ashley/core/EngineTests.java @@ -833,4 +833,13 @@ public void update(float deltaTime) { engine.update(0.0f); } + + @Test + public void createNewEntity () { + Engine engine = new Engine(); + Entity entity = engine.createEntity(); + + assertNotEquals(entity, null); + } + }