I call a "primitive" an object rendered with drawCircle(), drawRect(), …
Considering that:
- The positions of the primitives change (with constraint (1))
- The objects represented by the primitives* are frequently created/destroyed
What is the fastest way to draw multiple instances of the same primitives at different locations:
- Creating a graphics object, adding it to the container once for all, clearing it each frame, and calling multiples drawSomething() on it with different positions each frame ?
- Creating a graphics object for each primitive each frame, calling a single drawSomething() into it, and adding it to the container at a specified position ?
- Another solution ?
For the sake of clarity, if I have bullets simply rendered with drawCircle(), and knowing that I receive the complete state of the game each frame (that is the constraint (1)), what is the fastest way to render them all ?
(1): I do not know that at instant t bullet 1 is at position p1 and at instant t+1 bullet 1 is at position p2. But I do know that at instant t there is a bullet at position p1 and at instant t+1 there is a bullet at position p2.