B4A Library [Class] Sprites

The attached is a demo application showing how Sprites can be used (I can only think of game applications).
sprites are objects that move "by themselves" according to preset rules.
In the demo I show two types - a free-flyer and a path_walker.
I created two classes - one for the game zone and the other for the sprites.

I used GifDecoder Library by Agraham, and the idea of how to get the index in a common timer_tick from the spin-wheel thread.

For those who want different rules for the sprites - you can change it to suit your needs, that's what is so wonderful in classes, unlike libraries.

A problem: after launching several groups of sprites I usually get a memory problem. You can see in the RemoveSprite sub that I remove the imageview but I suspect that some variables still stay in memory. I don't know how to destroy the sprite object completely. Please advise.

Edit: Version 2 has better arrangement:
- azimuh range moved to the sprite type definition
- initialization of the sprite is done by reference to the game's type parameters array
- collision between same type sprites are igmored.
 

Attachments

  • screenshot.jpg
    screenshot.jpg
    90.9 KB · Views: 951
  • Aliens2.zip
    259.4 KB · Views: 808
Last edited:
Top