SetY() public method

public SetY ( int n ) : void
n int
return void
示例#1
0
        void OnDragged(int x, int y)
        {
            if (!ViewObjects)
            {
                OnClicked(x, y);
            }
            else
            {
                if (!draggingObject)
                {
                    return;
                }

                ObjectData data = objectEditor.SelectedObjectData;
                if (data != null && data.HasXY())
                {
                    int newX, newY;
                    if (gdkState.HasFlag(Gdk.ModifierType.ControlMask) || data.HasShortenedXY())
                    {
                        newX = x - XOffset;
                        newY = y - XOffset;
                    }
                    else
                    {
                        // Move objects in increments of 8 pixels
                        int unit    = 8;
                        int unitLog = (int)Math.Log(unit, 2);

                        int dataX  = data.GetX() + unit / 2;
                        int dataY  = data.GetY() + unit / 2;
                        int alignX = (dataX) % unit;
                        int alignY = (dataY) % unit;
                        newX = (x - XOffset - alignX) >> unitLog;
                        newY = (y - YOffset - alignY) >> unitLog;
                        newX = newX * unit + alignX + unit / 2;
                        newY = newY * unit + alignY + unit / 2;
                    }

                    if (newX >= 0 && newX < 256 && newY >= 0 && newY < 256)
                    {
                        data.SetX((byte)newX);
                        data.SetY((byte)newY);
                    }

                    QueueDraw();
                }
            }
        }
示例#2
0
        void OnDragged(int x, int y)
        {
            if (!ViewObjects)
            {
                OnClicked(x, y);
            }
            else
            {
                if (!IsInBounds(x, y))
                {
                    return;
                }
                if (!draggingObject)
                {
                    return;
                }

                ObjectData data = objectEditor.SelectedObjectData;
                if (data != null && data.HasXY())
                {
                    // Move objects in increments of 16 pixels
                    int dataX  = data.GetX() + 8;
                    int dataY  = data.GetY() + 8;
                    int alignX = (dataX) % 16;
                    int alignY = (dataY) % 16;
                    int newX   = (x - alignX) / 16;
                    int newY   = (y - alignY) / 16;
                    newX = (newX * 16 + alignX + 8) % 256;
                    newY = (newY * 16 + alignY + 8) % 256;

                    data.SetX(newX);
                    data.SetY(newY);

                    QueueDraw();
                }
            }
        }