Thank you for coming.
I wanna pin my player on the closest imagepoint of an object.
Top down game where every object rotates.
I have tried offset position without success, but now i am willing to use: imagepointX(N.)-player.X, take the smallest X.
The problem is, i don't know how to build it up on the events...
Develop games in your browser. Powerful, performant & highly capable.
How many imagepoints are there?
You can get the distance with distance(player.x,player.y,sprite.imagepointX(),sprite.ImagepointY())
like 8, all of them inside the object.
About the distance, the problem is returning in with the closest.
a creative way would be giving the object instance variables.
Dis1i, Dis2i, Dis3i, etc. and setting them to the distance to the player.
then you can do a sytem compare 2 for every one:
min(Dis1i,Dis2i, etc.) = Dis1i -> player pin to imagepoint1
min(Dis1i,Dis2i, etc.) = Dis2i -> player pin to imagepoint2
There are probably much better ways, but I'm trying to be creative here.
A much simpler solution would be to loop through each objects image points, testing its distance from the player, and then setting/pinning the player to the one with the shortest distance.
zatyka, yep, like I said, there are much better ways.
LittleStain and zatyka
My most sincere thanks.