ID:157705
 
Is it possible to 'grab' the most southern part of an icon, and then move the entire icon from that anchor, but the center of an icon is still in the center?

Because basically I'm trying to get a scalable ball object's most southern part to appear directly above you.
   m
MmM
MMmMM
MMMxMMM
MMmMM
MmM
m

The 'x' is the center of the icon. The small 'm's are the the Height() of the icon. I want to grab the 'm' pixel on the very bottom of the icon, and move it one tile above the players head. While moving this, the entire icon will follow the pixel I selected and moved. Imagine in photoshop where you you can grab any part of a picture, and you can drag it anywhere. Then imagine grabbing the bottom part, and moving it there.

I suck at explaining stuff, hope you can help me out.
There are potentially various ways to go about this, from what I understand of your question.

If you're dealing with an /icon object, the Shift() method would probably be useful for you.

If you're dealing with an atomic object, look up the pixel_y var.

As for "grabbing" the bottom of an icon, there are a few things I'd suggest.

A: Pre-calculate this value. This would be the fastest way.
B: If your ball has a variable size, keep track of its center and its radius. Then bottom_y = center_y - radius.
C: If all else fails---and this would be the slowest method---you could use lots of GetPixel() calls. Perhaps something like:
proc/get_bottom_y(icon/I, icon_state, dir=0, frame=0, moving=-1)
. = 1
// Start at (16,1) and move up until a pixel is found
while(!I.GetPixel(16, ., icon_state, dir, frame, moving))
++.
In response to Kuraudo
I would use pixel_y, except I have to keep the center of the icon the center. I use the range() proc to detect collision. So that's why I have to keep the icon centered the entire time.
In response to Strong123488
usr.Ball.pixel_y=size/32              usr.Ball.loc=locate(usr.x, usr.y+1, usr.z)

This will always make the most southern part of the ball appear above the players head. But the collision will also be detected from there, instead of the middle. Is there a way to make the ball appear above your head, without altering pixel_y

For instance
usr.Ball.loc=locate(usr.x, usr.y+size/100, usr.z)

Size is my predefined variable for the icons width or height.