Beispiel #1
0
        public CCFollow(CCNode followedNode, CCRect rect)
        {
            Debug.Assert(followedNode != null);

            FollowedNode = followedNode;
            if (rect.Equals(CCRect.Zero))
            {
                UsingBoundary = false;
            }
            else
            {
                UsingBoundary = true;
            }

            BoundaryFullyCovered = false;

            CCRect viewportBounds = followedNode.Layer.VisibleBoundsWorldspace;

            FullScreenSize = (CCPoint) new CCPoint(viewportBounds.Size.Width, viewportBounds.Size.Height);
            HalfScreenSize = FullScreenSize * 0.5f;

            if (UsingBoundary)
            {
                float leftBoundary   = -((rect.Origin.X + rect.Size.Width) - FullScreenSize.X - viewportBounds.Origin.X);
                float rightBoundary  = -rect.Origin.X;
                float topBoundary    = -rect.Origin.Y;
                float bottomBoundary = -((rect.Origin.Y + rect.Size.Height) - FullScreenSize.Y - viewportBounds.Origin.Y);

                if (rightBoundary < leftBoundary)
                {
                    // screen width is larger than world's boundary width
                    //set both in the middle of the world
                    rightBoundary = leftBoundary = (leftBoundary + rightBoundary) / 2;
                }
                if (topBoundary < bottomBoundary)
                {
                    // screen width is larger than world's boundary width
                    //set both in the middle of the world
                    topBoundary = bottomBoundary = (topBoundary + bottomBoundary) / 2;
                }

                if ((topBoundary == bottomBoundary) && (leftBoundary == rightBoundary))
                {
                    BoundaryFullyCovered = true;
                }

                Boundary = new CCFollowBoundary(bottomBoundary, leftBoundary, rightBoundary, topBoundary);
            }
        }
Beispiel #2
0
        public CCFollow(CCNode followedNode, CCRect rect)
        {
            Debug.Assert (followedNode != null);

            FollowedNode = followedNode;
            if (rect.Equals (CCRect.Zero))
            {
                UsingBoundary = false;
            }
            else
            {
                UsingBoundary = true;
            }

            BoundaryFullyCovered = false;

            CCRect viewportBounds = followedNode.Layer.VisibleBoundsWorldspace;
            FullScreenSize = (CCPoint)new CCPoint(viewportBounds.Size.Width, viewportBounds.Size.Height);
            HalfScreenSize = FullScreenSize * 0.5f;

            if (UsingBoundary)
            {
                float leftBoundary = -((rect.Origin.X + rect.Size.Width) - FullScreenSize.X - viewportBounds.Origin.X);
                float rightBoundary = -rect.Origin.X;
                float topBoundary = -rect.Origin.Y;
                float bottomBoundary = -((rect.Origin.Y + rect.Size.Height) - FullScreenSize.Y - viewportBounds.Origin.Y);

                if (rightBoundary < leftBoundary)
                {
                    // screen width is larger than world's boundary width
                    //set both in the middle of the world
                    rightBoundary = leftBoundary = (leftBoundary + rightBoundary) / 2;
                }
                if (topBoundary < bottomBoundary)
                {
                    // screen width is larger than world's boundary width
                    //set both in the middle of the world
                    topBoundary = bottomBoundary = (topBoundary + bottomBoundary) / 2;
                }

                if ((topBoundary == bottomBoundary) && (leftBoundary == rightBoundary))
                {
                    BoundaryFullyCovered = true;
                }

                Boundary = new CCFollowBoundary (bottomBoundary, leftBoundary, rightBoundary, topBoundary);
            }
        }