Hello guys,
in my game, I have following scenario:
- There are aliens moving on the screen
- Each alien has specific colour and "level’ - the level is represented by his size
- To eliminate him, you have to hit him with bullet of matching colour
- When you hit him with matching colour, his level decreases by 1 (represented by making him smaller) and his colour changes
- When you hit him with incorrect colour, his level increases by 1 (represented by making him bigger) and his colour changes to the colour of the bullet that hit him
- When you hit him “right” multiple times, his level goes to 0 and he dies
- When you hit him “wrong” multiple times, his level goes beyond pre-set limit and you have lost the game
- Attached is sample mockup to ilustrate the topic - the bigger circle represents the alien, the smaller one the bullet
My idea how to solve this is based on this
- Using physics engine
- Each alien has physics body attached
- Each alien has been set into movement by using the setLinearVelocity method
- Each alien’s display object handles collision event where the evaluation of successful/unsuccessful hit is performed and the appropriate “delayed” action is planned (via timer.performWithDelay(1, …))
- The action means to change the size and colour of alien
The problem I have is that I need to rebuild (remove and add new) the physics body after each hit when I want change size?
- The physics body properties cannot be changed - e.g. I cannot change the radius of the circular physics body
Is this an OK way of handling such kind of issue?
Would you use physics engine for this scenario at all?
