コード例 #1
0
        public override void OnEnter()
        {
            base.OnEnter();

            var origin = Layer.VisibleBoundsWorldspace.Size;

            var label1 = new CCLabel(string.Empty, "debuguncompressed", 0, CCLabelFormat.SpriteFont);

            var texture = label1.TextureAtlas != null ? label1.TextureAtlas.Texture : null;

            if (texture != null)
            {
                spriteFontNode       = new CCSprite(texture);
                spriteFontNode.Scale = 2;
            }
            else
            {
                spriteFontNode = new CCLabel("Texture can not be loaded", "arial", 24, CCLabelFormat.SpriteFont);
            }
            //spriteFontNode.Color = CCColor3B.Magenta;
            spriteFontNode.Position = origin.Center;


            AddChild(spriteFontNode);

            var itemUncompressed = new CCMenuItemLabel(new CCLabel("Uncompressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));
            var itemCompressed   = new CCMenuItemLabel(new CCLabel("Compressed", "fonts/arial", 24, CCLabelFormat.SpriteFont));

            itemUncompressed.AnchorPoint = CCPoint.AnchorMiddleLeft;
            itemCompressed.AnchorPoint   = CCPoint.AnchorMiddleLeft;
            var mi1  = new CCMenuItemToggle(OnToggle, itemUncompressed, itemCompressed);
            var menu = new CCMenu(mi1);

            AddChild(menu);
            menu.Position = VisibleBoundsWorldspace.Left();
        }
コード例 #2
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize windowSize = VisibleBoundsWorldspace.Size;

            var move = new CCMoveBy(4, new CCPoint(windowSize.Width / 2, 0));

            backGround.Position   = VisibleBoundsWorldspace.Left();
            backGround.PositionX += windowSize.Width / 4;

            // Run background animation
            backGround.RepeatForever(move, move.Reverse());

            backGround.DrawSolidCircle(CCPoint.Zero, 220, CCColor4B.White);
            AddChild(backGround);


            var color = CCColor4B.Red;
            var alpha = (byte)(255 * 0.3f);

            color.A = alpha;

            // Draw polygons
            //P1: 380:-160 P2: 200:-240 P3: 160:-420
            CCPoint[] points = new CCPoint[]
            {
                //P1: 380:-160 P2: 200:-240 P3: 160:-420
                new CCPoint(380, -160),
                new CCPoint(200, -240),
                new CCPoint(160, -420),
            };

            DrawSolidPolygon(points, color);

            //P1: 160:-420 P2: 200:-520 P3: 360:-540
            points[0] = new CCPoint(160, -420);
            points[1] = new CCPoint(200, -520);
            points[2] = new CCPoint(360, -540);

            DrawSolidPolygon(points, color);

            //P1: 360:-540 P2: 420:-600 P3: 520:-520
            points[0] = new CCPoint(360, -540);
            points[1] = new CCPoint(420, -600);
            points[2] = new CCPoint(530, -520);

            DrawSolidPolygon(points, color);

            //P1: 520:-520 P2: 380:-160 P3: 160:-420
            points[0] = new CCPoint(520, -520);
            points[1] = new CCPoint(380, -160);
            points[2] = new CCPoint(160, -420);

            DrawSolidPolygon(points, color);

            // P1: 160:-420 P2: 360:-540 P3: 520:-520
            points[0] = new CCPoint(160, -420);
            points[1] = new CCPoint(360, -540);
            points[2] = new CCPoint(520, -520);

            DrawSolidPolygon(points, color);

            drawTriangles.Position = windowSize.Center;
            // Offset by the bounds of the polygons to more or less center it
            drawTriangles.PositionX -= 370;
            drawTriangles.PositionY += 440;
        }