How to get delta time?

(Thorlucas) #1

For some reason I can’t seem to figure this out. The book says “Amethyst provides you with amethyst::core::timing::Time for that purpose”… and that’s about it. But how do I get the Time object?

Additionally I’m not understanding how to get the world object from a system’s run function.

(Abovegame) #2

In your system data you should put something like Read<'s, Time> and thats it (of course you need to put the argument as well in your run method).

(Thorlucas) #3

Got it! So time is a resource. An unrelated quick question:

In my state’s initialization/setup function, I’m generating some entities (just like how the pong tutorial says to do it). However, I also need to generate entities in my actual system in response to some changes. Because the way the entities generate is identical, DRY says I should only have one function that does that.

Idiomatically, where would this function go? In the state, then within the system find the state and call it? Or in the state, and within the system find the state and call it? Or somewhere totally unrelated?

The state gets a World struct while the system gets an Entities thing. So how could I possibly interchange them? I’d need two functions: one that does it through the entities thing and one that does it through a World struct. This doesn’t seem very clean. Yet spawning something on initialization and within frames is a common thing.

It also seems like the system “setup” function also gets a world — which would once again make the creature spawning function non-interchangeable.

Additionally where should the sprite sheet handle for this entity be stored? As a resource? In the state struct? Or in the system struct?

Thanks!