That is one way to do it, except it lacks the control over the strength of the 'gravitational pull'. Here is a snippet from my own game which is based on 'strength' (velocity)
while(!Obj_IsDeleted(bossObj)) {
x = GetPlayerX;
y = GetPlayerY;
dir = GetPointToPointAngle(GetEnemyX, GetEnemyY, GetPlayerX, GetPlayerY);
ObjMove_SetAngle(locPlayerID, dir);
vx = v * cos(dir);
vy = v * sin(dir);
ObjRender_SetPosition(locPlayerID, x + vx, y + vy, 0);
yield;
}