Вопрос

I am working on a project in libgdx and i am stuck at a point I want an algorithm or Java code so that I can create multiple explosion whenever I click on screen irrespective to the one which is already running , if I click on screen 10 times at a time I can see 10 explosions. Please help me to do this?

Это было полезно?

Решение

One solution:

Keep an Array<> of running explosions. On render, iterate through them - for each one that is not finsihed, draw. Then, loop through and remove the finished ones and release back to the pool (if you are using pooling, which you really should), or dispose. You could combine these steps by using a DelayedRemovalArray<> and use begin() before starting the loop and end() after.

On click, add a new effect to the array.

I used this method to create an "area effect" explosion where lots of explosion effects are spawned over a set time.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top