implement getNearestSprite function in GameObject