How to ues `World::create_iter`?

(Elijah Voigt) #1

I have a bunch of times I’m creating very similar entities – say a dozen “Books”.

My current code looks like this:

for (x,y) in platform_coordinates {
        ... etc ...

This is a simplification. The jist of it is that for each platform I’m calling world.create_entity().

I just saw in the API docs we also have World::create_iter() which seems like it would be more suited for creating batches of similar entities, but I’m not sure how to use it.

The docs list this example:

use specs::prelude::*;
let mut world = World::new();
let five_entities: Vec<_> = world.create_iter().take(5).collect();

My question is, how would I add components to the above five entities? Do I use a map kinda deal or what?

Once I have a better grasp on how to use this API I’m excited to update the API docs to be more helpful.

1 Like
(Nathan) #2

I don’t know the answer, but more importantly it appears that World::create_iter() no longer exists in version 0.15.0…so I’m going to say you probably shouldn’t try to use it.

On a related note, it looks like docs didn’t generate for version 0.14.0 or version 0.15.0…which is no good.

(Elijah Voigt) #3

Good catch. I made an issue about the broken API docs:

(Nathan) #4

Since my last post in this thread, I’ve learned that because of compile times our docs are hosted on