public static int CenterX(Sprite sprite, int x) { int newX = x - (sprite.GetWidth() / 2); if (newX + sprite.GetWidth() >= LSystem.screenRect.width) { return(LSystem.screenRect.width - sprite.GetWidth() - 1); } if (newX < 0) { return(x); } else { return(newX); } }
public static int CenterX(Sprite sprite, int x) { int newX = x - (sprite.GetWidth() / 2); if (newX + sprite.GetWidth() >= LSystem.screenRect.width) { return (LSystem.screenRect.width - sprite.GetWidth() - 1); } if (newX < 0) { return x; } else { return newX; } }