Skip to content
Advertisement

Remove object particle with kivy condition

What I want is two things: count the number of enemies on the screen. And remove all enemies from the screen with a contion. The second chose is to allow enemies to shoot randomly

JavaScript

What I want is two things: count the number of enemies on the screen. And remove all enemies from the screen with a contion. The second chose is to allow enemies to shoot randomly

Advertisement

Answer

You can accomplish the first two of your questions by modifying the PSWidget class. By adding two attributes enemy_count and killall to the class:

JavaScript

And using those attributes in the update_glsl() method:

JavaScript

So, anytime you want the count of active enemies, just use the enemy_count attribute of the PSWidget instance. And whenever you want to kill all the active enemies, just set the killall attribute of the PSWidget instance.

As far as your third question, show us your attempt at coding that.

If you are using an answer that I gave in another question, where I suggested using the on_enter() method to start the game updates, then you can use on_leave() to stop the updates. The game movements are faster every time you enter MainScreen because more updates are scheduled on each entry. Here is a modified MainScreen that handles that handles that issue:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement