Function and Demo here:
http://www.artsystems.com.au/game%20editor/getClosestClone%20DEMO.zip
Actor *getClosestClone( char *actorName, double range)
{
Actor *resultActor = getclone("invalid.0");
Actor *testActor;
int maxClones = 64;
int i = 0;
double testDistance;
double minDistance = range;
while ( i < maxClones )
{
testActor = getclone2( actorName, i );
if ( testActor ->cloneindex != -1 )
{
testDistance = distance ( x, y , testActor->x, testActor->y );
if ( testDistance < minDistance )
{
minDistance = testDistance;
resultActor = testActor;
}
}
i++;
}
return resultActor;
}
Users browsing this forum: No registered users and 1 guest