Пример #1
0
        public override void Setup()
        {
			CCClippingNode clipper = new CCClippingNode() { Tag = kTagClipperNode };
            clipper.ContentSize = new CCSize(200, 200);
            clipper.AnchorPoint = new CCPoint(0.5f, 0.5f);
            AddChild(clipper);

            CCDrawNode stencil = new CCDrawNode();
            CCPoint[] rectangle =
                {
                    new CCPoint(0, 0),
                    new CCPoint(clipper.ContentSize.Width, 0),
                    new CCPoint(clipper.ContentSize.Width, clipper.ContentSize.Height),
                    new CCPoint(0, clipper.ContentSize.Height),
                };

            CCColor4F white = new CCColor4F(0, 0, 0, 1);
            stencil.DrawPolygon(rectangle, 4, white, 0, white);
            clipper.Stencil = stencil;

            CCSprite content = new CCSprite(TestResource.s_back2);
            content.Tag = kTagContentNode;
            content.AnchorPoint = new CCPoint(0.5f, 0.5f);
            clipper.AddChild(content);

            content.RunAction(new CCRepeatForever(new CCRotateBy(1, 45)));

            m_bScrolling = false;

			// Register Touch Event
			var touchListener = new CCEventListenerTouchAllAtOnce();

			touchListener.OnTouchesBegan = onTouchesBegan;
			touchListener.OnTouchesMoved = onTouchesMoved;
			touchListener.OnTouchesEnded = onTouchesEnded;

            AddEventListener(touchListener);        
		}
Пример #2
0
		void PositionInWindow (CCClippingNode clipper)
		{
			clipper.Position = clipper.Parent.ContentSize.Center;

			foreach (var child in clipper.Children)
			{
				if (child is CCClippingNode)
				{
					var clipr = (CCClippingNode)child;
					clipr.Stencil.Position = clipr.ContentSize.Center;

					PositionInWindow(clipr);

				}

			}
		}
Пример #3
0
        public override void Setup()
        {
            CCSprite target = new CCSprite(TestResource.s_pPathBlock);
            target.AnchorPoint = CCPoint.Zero;
            target.Scale = 3;

			m_pOuterClipper = new CCClippingNode();

            CCAffineTransform tranform = CCAffineTransform.Identity;
			tranform = CCAffineTransform.ScaleCopy(tranform, target.ScaleX, target.ScaleY);

            m_pOuterClipper.ContentSize = CCAffineTransform.Transform(target.ContentSize, tranform);
            m_pOuterClipper.AnchorPoint = new CCPoint(0.5f, 0.5f);
            m_pOuterClipper.RunAction(new CCRepeatForever(new CCRotateBy(1, 45)));

            m_pOuterClipper.Stencil = target;

            CCClippingNode holesClipper = new CCClippingNode();
            holesClipper.Inverted = true;
            holesClipper.AlphaThreshold = 0.05f;

            holesClipper.AddChild(target);

            m_pHoles = new CCNode();

            holesClipper.AddChild(m_pHoles);

            m_pHolesStencil = new CCNode();

            holesClipper.Stencil = m_pHolesStencil;

            m_pOuterClipper.AddChild(holesClipper);

            this.AddChild(m_pOuterClipper);

			var listener = new CCEventListenerTouchAllAtOnce();
			listener.OnTouchesBegan = onTouchesBegan;

            AddEventListener(listener);    
        }
Пример #4
0
        public override void Setup()
        {
            const int depth = 9;

            CCNode parent = this;

            for (int i = 0; i < depth; i++)
            {

                int size = 225 - i * (225 / (depth * 2));

                CCClippingNode clipper = new CCClippingNode();
                clipper.ContentSize = new CCSize(size, size);
                clipper.AnchorPoint = new CCPoint(0.5f, 0.5f);
				clipper.Position = parent.ContentSize.Center;
                clipper.AlphaThreshold = 0.05f;
                clipper.RunAction(new CCRepeatForever(new CCRotateBy(i % 3 != 0 ? 1.33f : 1.66f, i % 2 != 0 ? 90 : -90)));
                parent.AddChild(clipper);

                CCNode stencil = new CCSprite(TestResource.s_pPathGrossini);
                stencil.Scale = 2.5f - (i * (2.5f / depth));
                stencil.AnchorPoint = new CCPoint(0.5f, 0.5f);
				stencil.Position = clipper.ContentSize.Center;
                stencil.Visible = false;
                stencil.RunAction(new CCSequence(new CCDelayTime(i), new CCShow()));
                clipper.Stencil = stencil;

                clipper.AddChild(stencil);

                parent = clipper;
            }
        }