Ejemplo n.º 1
0
        protected internal override void ProcessTouchDragged()
        {
            int dropX = 0;
            int dropY = 0;

            if (!locked)
            {
                bool moveActor = false;
                if (actorDrag)
                {
                    lock (objects)
                    {
                        dropX = this.input.GetTouchX() - this.GetScreenX();
                        dropY = this.input.GetTouchY() - this.GetScreenY();
                        if (dragActor == null)
                        {
                            dragActor = GetSynchronizedObject(dropX, dropY);
                        }
                        if (dragActor != null && dragActor.IsDrag())
                        {
                            lock (dragActor)
                            {
                                objects.SendToFront(dragActor);
                                RectBox rect = dragActor.GetBoundingRect();
                                int     dx   = (dropX - (rect.width / 2));
                                int     dy   = (dropY - (rect.height / 2));
                                if (dragActor.GetLLayer() != null)
                                {
                                    dragActor.SetLocation(dx, dy);
                                    dragActor.Drag(dropX, dropY);
                                    if (dragActor.actorListener != null)
                                    {
                                        dragActor.actorListener.Drag(dropX, dropY);
                                    }
                                }
                                moveActor = true;
                            }
                        }
                    }
                }
                if (!moveActor)
                {
                    lock (input)
                    {
                        dropX = this.input.GetTouchDX();
                        dropY = this.input.GetTouchDY();
                        if (IsNotMoveInScreen(dropX + this.X(), dropY + this.Y()))
                        {
                            return;
                        }
                        if (GetContainer() != null)
                        {
                            GetContainer().SendToFront(this);
                        }
                        this.Move(dropX, dropY);
                        this.Drag(dropX, dropY);
                    }
                }
            }
            else
            {
                if (!actorDrag)
                {
                    return;
                }
                lock (objects)
                {
                    dropX = this.input.GetTouchX() - this.GetScreenX();
                    dropY = this.input.GetTouchY() - this.GetScreenY();
                    if (dragActor == null)
                    {
                        dragActor = GetSynchronizedObject(dropX, dropY);
                    }
                    if (dragActor != null && dragActor.IsDrag())
                    {
                        lock (dragActor)
                        {
                            objects.SendToFront(dragActor);
                            RectBox rect = dragActor.GetBoundingRect();
                            int     dx   = (dropX - (rect.width / 2));
                            int     dy   = (dropY - (rect.height / 2));
                            if (dragActor.GetLLayer() != null)
                            {
                                dragActor.SetLocation(dx, dy);
                                dragActor.Drag(dropX, dropY);
                                if (dragActor.actorListener != null)
                                {
                                    dragActor.actorListener.Drag(dropX, dropY);
                                }
                            }
                        }
                    }
                }
            }
        }