protected void ShowSprite( ISprite newSprite, ResizeModeX modeX = ResizeModeX.Center, ResizeModeY modeY = ResizeModeY.Bottom) { sprite = newSprite; Resize(sprite.PixelSize, modeX, modeY); }
protected void Resize(Point newSize, ResizeModeX modeX, ResizeModeY modeY) { Point delta = new Point(); switch (modeX) { case ResizeModeX.Left: delta.X = 0; break; case ResizeModeX.Center: delta.X = (size.X - newSize.X) / 2; break; case ResizeModeX.Right: delta.X = size.X - newSize.X; break; } switch (modeY) { case ResizeModeY.Top: delta.Y = 0; break; case ResizeModeY.Center: delta.Y = (size.Y - newSize.Y) / 2; break; case ResizeModeY.Bottom: delta.Y = size.Y - newSize.Y; break; } Relocate(Location + delta); size = newSize; World.Move(this); }