If something does not work, it usually is a good chance to learn something. You were given two (IMHO perfectly valid) solutions, yet you failed to look at each of them closely enough to make use of them.
StickFigs wrote:Is telling me that the two sprites are at the same exact position which isn't true
AE's source is open. If you are using eclipse, by pressing F3 on a getSceneCenterCoordinates() you can eventually find out, that this method uses returns a
static array as a result:
Using java Syntax Highlighting
private static final float[] VERTICES_LOCAL_TO_SCENE_TMP = new float[2];
Parsed in 0.033 seconds, using
GeSHi 1.0.8.4
This means, that by calling getSceneCenterCoordinates() method twice, you overwrite the result of the first call.
To make it work, you have two options:
1. Do not call getSceneCenterCoordinates() one-after-another.
Using java Syntax Highlighting
float[] slotPos = slot.tiledSprite.getSceneCenterCoordinates();
Log.d(this.toString(), "Slot Position = "+slotPos[0]+","+slotPos[1]);
float[] objPos = obj.sprite.getSceneCenterCoordinates();
Log.d(this.toString(), "Object Position = "+objPos[0]+","+objPos[1]);
Parsed in 0.037 seconds, using
GeSHi 1.0.8.4
2. Provide a local arrays which will be used instead of a static one
Using java Syntax Highlighting
float[] slotPos = new float[2];
float[] objPos = new float[2];
slotPos = slot.tiledSprite.getSceneCenterCoordinates(slotPos);
objPos = obj.sprite.getSceneCenterCoordinates(objPos);
float dist = (float) Math.hypot(slotPos[0] - objPos[0], slotPos[1] - objPos[1]);
Log.d(this.toString(), "Slot Position = "+slotPos[0]+","+slotPos[1]);
Log.d(this.toString(), "Object Position = "+objPos[0]+","+objPos[1]);
Log.d(this.toString(), "Distance = "+dist);
Parsed in 0.038 seconds, using
GeSHi 1.0.8.4
I'm not saying your question was bad. I am saying that your attitude was- do not expect everything to be solved for ya.