Skip to content Skip to sidebar Skip to footer

Andengine Tower Defence Game - Enemy<-weapon Interaction

What is the most correct from the performance point of view - algorithm of interaction between Enemy and Weapon(bullet maybe more correct here) ? Should every sprite every single

Solution 1:

The best way to approach this is to use Physics Box2D extension. It will handle the collisions for you. Use Fixed Step Physics Engine to increase performance.

  1. You can add your own property to TMX maps - to each object, group etc. I recommend creating a property on objects that are enemies, because I believe they will be in your TMX map. In your code attach a physics engine body to each object with that property. Look at this example: http://www.andengine.org/forums/tutorials/collision-objects-from-tmx-map-t3907.html

  2. When you fire a bullet, attach a body to it as well. Make it a sensor, so it won't bounce of other objects (unless you want it to). Let the Box2D handle the collisions and you handle the aftermath! Example: http://www.andengine.org/forums/gles2/collision-events-t7140.html#p31300

Go through the AndEngine examples, most of what you want, is already there: https://github.com/nicolasgramlich/AndEngineExamples/tree/GLES2/src/org/andengine/examples

Post a Comment for "Andengine Tower Defence Game - Enemy<-weapon Interaction"