Resources are based on: https://github.com/leerob/Space_Invaders/
Previous example: https://www.b4x.com/android/forum/threads/xui2d-space-invaders-1.96263/
New features in this example:
- shields
- mystery enemy (red enemy)
- high scores
- explosion graphics
- and some other small improvements.
If we run the game with debug drawing then we can see that the shields are made of many small fixtures:

This allows us to destroy small parts of the shields. See the code in the Shield class.
There are three new methods in X2Utils:
- AddFutureTask2 - Similar to AddFutureTask. Allows to add duplicate future tasks. Duplicate means FutureTasks with the same Callback, SubName and Time.
- GetBodyWrapper - Returns a X2BodyWrapper based on the Id. The Id field is a new field that is set from the tile map object id. You can also set programmatically.
- GetBodiesWrappers - Returns a list with all bodies with ids listed in the ListOfIds parameter.
I'm using GetBodiesWrappers instead of the Enemies list that was maintained in the previous example. The advantage is that we don't need to worry about the list not being synchronized and we let XUI2D maintain it for us.
Example projects included in the examples pack: https://www.b4x.com/android/forum/threads/xui2d-example-pack.96454/
Last edited: