I am following the jME beginners guide book, and building example tower defense project. At the end of Chapter 3 towers check the distance between the tower and the incoming creeps using the Control attached with the creep.
My question is, why use control to check distance? Why not just use Geometry local translation to calculate the distance.
Right now, I have a getter method to get the arraylist of creep geometry and calculate the distance using getLocalTranslation().
Just based on the excerpt you’ve provided and your questions… the question kind of makes no sense.
“Using a control to check distance” is about WHEN to run things. “Why not just use Geometry local translation to calculate distance” is about HOW to calculate things.
For example, if you go with Geometry to calculate distance… when do you run that code? Where?
it loops over the ArrayList of creep objects that it gets from the GamePlayAppState object, and uses the creep_geo.getControl(CreepControl.class) method to get access to the CreepControl object. The tower determines whether the distance between itself and each creep is lower than a certain value.
Why access controls attached to creep when we can access the geometry.
I’ve found it. The book is asking to add control instead of the Geometry because later we want to call methods implemented in that custom control class.