当前位置: 首页>>代码示例>>C#>>正文


C# CCNode.AddChild方法代码示例

本文整理汇总了C#中cocos2d.CCNode.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# CCNode.AddChild方法的具体用法?C# CCNode.AddChild怎么用?C# CCNode.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cocos2d.CCNode的用法示例。


在下文中一共展示了CCNode.AddChild方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TextLayer

        public TextLayer()
        {
            InitWithColor(CCTypes.CreateColor(32, 32, 32, 255));

            float x, y;

            CCSize size = CCDirector.SharedDirector.WinSize;
            x = size.Width;
            y = size.Height;

            CCNode node = new CCNode ();
            CCActionInterval effect = getAction();
            node.RunAction(effect);
            AddChild(node, 0, EffectTestScene.kTagBackground);

            CCSprite bg = new CCSprite(TestResource.s_back3);
            node.AddChild(bg, 0);
            bg.AnchorPoint = new CCPoint(0.5f, 0.5f);
            bg.Position = new CCPoint(size.Width / 2, size.Height / 2);

            CCSprite grossini = new CCSprite(TestResource.s_pPathSister2);
            node.AddChild(grossini, 1);
            grossini.Position = new CCPoint(x / 3, y / 2);
            CCActionInterval sc = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc_back = sc.Reverse();
            grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back))));
            //grossini.runAction(effect);

            CCSprite tamara = new CCSprite(TestResource.s_pPathSister1);
            node.AddChild(tamara, 1);
            tamara.Position = new CCPoint(2 * x / 3, y / 2);
            CCActionInterval sc2 = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc2_back = sc2.Reverse();
            tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back))));

            CCLabelTTF label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32);

            label.Position = new CCPoint(x / 2, y - 80);
            AddChild(label);
            label.Tag = EffectTestScene.kTagLabel;

            CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            CCMenu menu = new CCMenu(item1, item2, item3);

            menu.Position = new CCPoint(0, 0);
            item1.Position = new CCPoint(size.Width / 2 - 100, 30);
            item2.Position = new CCPoint(size.Width / 2, 30);
            item3.Position = new CCPoint(size.Width / 2 + 100, 30);

            AddChild(menu, 1);

            Schedule(checkAnim);
        }
开发者ID:KogleDK,项目名称:cocos2d-xna-1,代码行数:56,代码来源:TextLayer.cs

示例2: Init

        public override bool Init()
        {
            if (base.Init())
            {
                CCSize screenSize = CCDirector.SharedDirector.WinSize;

                CCNode layer = new CCNode ();
                layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
                AddChild(layer, 1);

                float layer_width = 0.0f;

                // Add the black background for the text
                CCScale9Sprite background = CCScale9Sprite.Create("extensions/buttonBackground");
                background.ContentSize = new CCSize(80, 50);
                background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
                layer.AddChild(background);

                layer_width += background.ContentSize.Width;

                m_pDisplayValueLabel = new CCLabelTTF("#color", "Marker Felt", 30);

                m_pDisplayValueLabel.Position = background.Position;
                layer.AddChild(m_pDisplayValueLabel);

                // Create the switch
                CCControlSwitch switchControl = CCControlSwitch.Create
                    (
                        new CCSprite("extensions/switch-mask"),
                        new CCSprite("extensions/switch-on"),
                        new CCSprite("extensions/switch-off"),
                        new CCSprite("extensions/switch-thumb"),
                        new CCLabelTTF("On", "Arial-BoldMT", 16),
                        new CCLabelTTF("Off", "Arial-BoldMT", 16)
                    );
                switchControl.Position = new CCPoint(layer_width + 10 + switchControl.ContentSize.Width / 2, 0);
                layer.AddChild(switchControl);

                switchControl.AddTargetWithActionForControlEvents(this, valueChanged, CCControlEvent.ValueChanged);

                // Set the layer size
                layer.ContentSize = new CCSize(layer_width, 0);
                layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

                // Update the value label
                valueChanged(switchControl, CCControlEvent.ValueChanged);
                return true;
            }
            return false;
        }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:50,代码来源:CCControlSwitchTest.cs

示例3: SpriteZVertex

        public SpriteZVertex()
        {
            //
            // This test tests z-order
            // If you are going to use it is better to use a 3D projection
            //
            // WARNING:
            // The developer is resposible for ordering it's sprites according to it's Z if the sprite has
            // transparent parts.
            //

            m_dir = 1;
            m_time = 0;

            CCSize s = CCDirector.SharedDirector.WinSize;
            float step = s.Width / 12;

            CCNode node = new CCNode ();
            // camera uses the center of the image as the pivoting point
            node.ContentSize = (new CCSize(s.Width, s.Height));
            node.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            node.Position = (new CCPoint(s.Width / 2, s.Height / 2));

            AddChild(node, 0);

            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));
                sprite.VertexZ = (10 + i * 40);
                node.AddChild(sprite, 0);
            }

            for (int i = 5; i < 11; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));
                sprite.VertexZ = 10 + (10 - i) * 40;
                node.AddChild(sprite, 0);
            }

            node.RunAction(new CCOrbitCamera(10, 1, 0, 0, 360, 0, 0));
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:43,代码来源:SpriteZVertex.cs

示例4: SpriteChildrenVisibilityIssue665

        public SpriteChildrenVisibilityIssue665()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");

            CCNode aParent;
            CCSprite sprite1, sprite2, sprite3;
            //
            // SpriteBatchNode
            //
            // parents
            aParent = new CCSpriteBatchNode("animations/grossini", 50);
            aParent.Position = (new CCPoint(s.Width / 3, s.Height / 2));
            AddChild(aParent, 0);

            sprite1 = new CCSprite("grossini_dance_01.png");
            sprite1.Position = (new CCPoint(0, 0));

            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite2.Position = (new CCPoint(20, 30));

            sprite3 = new CCSprite("grossini_dance_03.png");
            sprite3.Position = (new CCPoint(-20, 30));

            // test issue #665
            sprite1.Visible = false;

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, 2);

            //
            // Sprite
            //
            aParent = new CCNode ();
            aParent.Position = (new CCPoint(2 * s.Width / 3, s.Height / 2));
            AddChild(aParent, 0);

            sprite1 = new CCSprite("grossini_dance_01.png");
            sprite1.Position = (new CCPoint(0, 0));

            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite2.Position = (new CCPoint(20, 30));

            sprite3 = new CCSprite("grossini_dance_03.png");
            sprite3.Position = (new CCPoint(-20, 30));

            // test issue #665
            sprite1.Visible = false;

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, 2);
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:55,代码来源:SpriteChildrenVisibilityIssue665.cs

示例5: SpriteHybrid

        public SpriteHybrid()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            // parents
            CCNode parent1 = new CCNode ();
            CCSpriteBatchNode parent2 = new CCSpriteBatchNode("animations/grossini", 50);

            AddChild(parent1, 0, (int)kTags.kTagNode);
            AddChild(parent2, 0, (int)kTags.kTagSpriteBatchNode);

            // IMPORTANT:
            // The sprite frames will be cached AND RETAINED, and they won't be released unless you call
            //     CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames);
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");

            // create 250 sprites
            // only show 80% of them
            for (int i = 0; i < 250; i++)
            {
                int spriteIdx = (int)(Random.NextDouble() * 14);
                string str = "";
                string temp = "";
                if (spriteIdx+1<10)
                {
                    temp = "0" + (spriteIdx+1);
                }
                else
                {
                    temp = (spriteIdx+1).ToString();
                }
                str = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str);
                CCSprite sprite = new CCSprite(frame);
                parent1.AddChild(sprite, i, i);

                float x = -1000;
                float y = -1000;
                if (Random.NextDouble() < 0.2f)
                {
                    x = (float)(Random.NextDouble() * s.Width);
                    y = (float)(Random.NextDouble() * s.Height);
                }
                sprite.Position = (new CCPoint(x, y));

                CCActionInterval action = new CCRotateBy (4, 360);
                sprite.RunAction(new CCRepeatForever (action));
            }

            m_usingSpriteBatchNode = false;

            Schedule(reparentSprite, 2);
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:53,代码来源:SpriteHybrid.cs

示例6: AddSpriteToTargetWithPosAndAnchor

        public static CCSprite AddSpriteToTargetWithPosAndAnchor(string spriteName, CCNode target, CCPoint pos, CCPoint anchor)
        {
            var sprite = new CCSprite(spriteName);

            if (sprite == null)
                return null;

            sprite.Position = pos;
            sprite.AnchorPoint = anchor;
            target.AddChild(sprite);

            return sprite;
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:13,代码来源:CCControlUtils.cs

示例7: OnEnter

        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            // the root object just rotates around
            m_root = new CCSprite(s_pPathR1);
            AddChild(m_root, 1);
            m_root.Position = new CCPoint(s.Width / 2, s.Height / 2);

            // the target object is offset from root, and the streak is moved to follow it
            m_target = new CCSprite(s_pPathR1);
            m_root.AddChild(m_target);
            m_target.Position = new CCPoint(s.Width / 4, 0);

            // create the streak object and add it to the scene
            streak = CCMotionStreak.Create(2, 3, 32, CCTypes.CCGreen, s_streak);
            streak.FastMode = true;
            AddChild(streak);
            // schedule an update on each frame so we can syncronize the streak with the target
            Schedule(onUpdate);

            var a1 = new CCRotateBy (2, 360);

            var action1 = new CCRepeatForever (a1);
            var motion = new CCMoveBy (2, new CCPoint(100, 0));
            m_root.RunAction(new CCRepeatForever ((CCActionInterval)CCSequence.FromActions(motion, motion.Reverse())));
            m_root.RunAction(action1);

            var colorAction = new CCRepeatForever ((CCActionInterval)
                CCSequence.FromActions(
                    new CCTintTo (0.2f, 255, 0, 0),
                    new CCTintTo (0.2f, 0, 255, 0),
                    new CCTintTo (0.2f, 0, 0, 255),
                    new CCTintTo (0.2f, 0, 255, 255),
                    new CCTintTo (0.2f, 255, 255, 0),
                    new CCTintTo (0.2f, 255, 0, 255),
                    new CCTintTo (0.2f, 255, 255, 255)
                    )
                );

            streak.RunAction(colorAction);
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:44,代码来源:MotionStreakTest1.cs

示例8: SpriteBatchNodeChildrenScale

        public SpriteBatchNodeChildrenScale()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini_family.plist");

            CCNode aParent;
            CCSprite sprite1, sprite2;
            CCActionInterval rot = new CCRotateBy (10, 360);
            CCAction seq = new CCRepeatForever (rot);

            //
            // Children + Scale using Sprite
            // Test 1
            //
            aParent = new CCNode ();
            sprite1 = new CCSprite("grossinis_sister1.png");
            sprite1.Position = new CCPoint(s.Width / 4, s.Height / 4);
            sprite1.ScaleX = -0.5f;
            sprite1.ScaleY = 2.0f;
            sprite1.RunAction(seq);

            sprite2 = new CCSprite("grossinis_sister2.png");
            sprite2.Position = (new CCPoint(50, 0));

            AddChild(aParent);
            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2);

            //
            // Children + Scale using SpriteBatchNode
            // Test 2
            //

            aParent = new CCSpriteBatchNode("animations/grossini_family");
            sprite1 = new CCSprite("grossinis_sister1.png");
            sprite1.Position = new CCPoint(3 * s.Width / 4, s.Height / 4);
            sprite1.ScaleX = -0.5f;
            sprite1.ScaleY = 2.0f;
            sprite1.RunAction((CCAction)(seq.Copy()));

            sprite2 = new CCSprite("grossinis_sister2.png");
            sprite2.Position = (new CCPoint(50, 0));

            AddChild(aParent);
            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2);

            //
            // Children + Scale using Sprite
            // Test 3
            //

            aParent = new CCNode ();
            sprite1 = new CCSprite("grossinis_sister1.png");
            sprite1.Position = (new CCPoint(s.Width / 4, 2 * s.Height / 3));
            sprite1.ScaleX = (1.5f);
            sprite1.ScaleY = -0.5f;
            sprite1.RunAction((CCAction)(seq.Copy()));

            sprite2 = new CCSprite("grossinis_sister2.png");
            sprite2.Position = (new CCPoint(50, 0));

            AddChild(aParent);
            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2);

            //
            // Children + Scale using Sprite
            // Test 4
            //

            aParent = new CCSpriteBatchNode("animations/grossini_family");
            sprite1 = new CCSprite("grossinis_sister1.png");
            sprite1.Position = (new CCPoint(3 * s.Width / 4, 2 * s.Height / 3));
            sprite1.ScaleX = 1.5f;
            sprite1.ScaleY = -0.5f;
            sprite1.RunAction((CCAction)(seq.Copy()));

            sprite2 = new CCSprite("grossinis_sister2.png");
            sprite2.Position = (new CCPoint(50, 0));

            AddChild(aParent);
            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2);
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:86,代码来源:SpriteBatchNodeChildrenScale.cs

示例9: SpriteChildrenChildren

        public SpriteChildrenChildren()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/ghosts.plist");

            CCNode aParent;
            CCSprite l1, l2a, l2b, l3a1, l3a2, l3b1, l3b2;
            CCActionInterval rot = new CCRotateBy (10, 360);
            CCAction seq = new CCRepeatForever (rot);

            CCActionInterval rot_back = (CCActionInterval)rot.Reverse();
            CCAction rot_back_fe = new CCRepeatForever (rot_back);

            //
            // SpriteBatchNode: 3 levels of children
            //

            aParent = new CCNode ();
            AddChild(aParent);

            // parent
            l1 = new CCSprite("father.gif");
            l1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            l1.RunAction((CCAction)(seq.Copy()));
            aParent.AddChild(l1);
            CCSize l1Size = l1.ContentSize;

            // child left
            l2a = new CCSprite("sister1.gif");
            l2a.Position = (new CCPoint(-50 + l1Size.Width / 2, 0 + l1Size.Height / 2));
            l2a.RunAction((CCAction)(rot_back_fe.Copy()));
            l1.AddChild(l2a);
            CCSize l2aSize = l2a.ContentSize;

            // child right
            l2b = new CCSprite("sister2.gif");
            l2b.Position = (new CCPoint(+50 + l1Size.Width / 2, 0 + l1Size.Height / 2));
            l2b.RunAction((CCAction)(rot_back_fe.Copy()));
            l1.AddChild(l2b);
            CCSize l2bSize = l2a.ContentSize;

            // child left bottom
            l3a1 = new CCSprite("child1.gif");
            l3a1.Scale = 0.45f;
            l3a1.Position = new CCPoint(0 + l2aSize.Width / 2, -100 + l2aSize.Height / 2);
            l2a.AddChild(l3a1);

            // child left top
            l3a2 = new CCSprite("child1.gif");
            l3a2.Scale = 0.45f;
            l3a1.Position = (new CCPoint(0 + l2aSize.Width / 2, +100 + l2aSize.Height / 2));
            l2a.AddChild(l3a2);

            // child right bottom
            l3b1 = new CCSprite("child1.gif");
            l3b1.Scale = 0.45f;
            l3b1.FlipY = true;
            l3b1.Position = (new CCPoint(0 + l2bSize.Width / 2, -100 + l2bSize.Height / 2));
            l2b.AddChild(l3b1);

            // child right top
            l3b2 = new CCSprite("child1.gif");
            l3b2.Scale = 0.45f;
            l3b2.FlipY = true;
            l3b1.Position = new CCPoint(0 + l2bSize.Width / 2, +100 + l2bSize.Height / 2);
            l2b.AddChild(l3b2);
        }
开发者ID:HarkDev,项目名称:cocos2d-xna,代码行数:68,代码来源:SpriteChildrenChildren.cs

示例10: Init

        public override bool Init()
        {
            if (base.Init())
            {
                CCSize screenSize = CCDirector.SharedDirector.WinSize;

                var layer = new CCNode ();
                AddChild(layer, 1);

                int space = 10; // px

                float max_w = 0, max_h = 0;
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 3; j++)
                    {

                        // Add the buttons
                        var button = standardButtonWithTitle(Random.Next(30).ToString());
                        button.SetAdjustBackgroundImage(false);  // Tells the button that the background image must not be adjust
                                                            // It'll use the prefered size of the background image
                        button.Position = new CCPoint(button.ContentSize.Width / 2 + (button.ContentSize.Width + space) * i,
                                               button.ContentSize.Height / 2 + (button.ContentSize.Height + space) * j);
                        layer.AddChild(button);

                        max_w = Math.Max(button.ContentSize.Width * (i + 1) + space * i, max_w);
                        max_h = Math.Max(button.ContentSize.Height * (j + 1) + space * j, max_h);
                    }
                }

                layer.AnchorPoint = new CCPoint (0.5f, 0.5f);
                layer.ContentSize = new CCSize(max_w, max_h);
                layer.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);

                // Add the black background
                var backgroundButton = CCScale9Sprite.Create("extensions/buttonBackground");
                backgroundButton.ContentSize = new CCSize(max_w + 14, max_h + 14);
                backgroundButton.Position = new CCPoint(screenSize.Width / 2.0f, screenSize.Height / 2.0f);
                AddChild(backgroundButton);
                return true;
            }
            return false;
        }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:43,代码来源:CCControlButtonTest.cs

示例11: SpriteChildrenAnchorPoint

        public SpriteChildrenAnchorPoint()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist");

            CCNode aParent;
            CCSprite sprite1, sprite2, sprite3, sprite4, point;
            //
            // SpriteBatchNode
            //
            // parents

            aParent = new CCNode ();
            AddChild(aParent, 0);

            // anchor (0,0)
            sprite1 = new CCSprite("grossini_dance_08.png");
            sprite1.Position = (new CCPoint(s.Width / 4, s.Height / 2));
            sprite1.AnchorPoint = (new CCPoint(0, 0));

            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite2.Position = (new CCPoint(20, 30));

            sprite3 = new CCSprite("grossini_dance_03.png");
            sprite3.Position = (new CCPoint(-20, 30));

            sprite4 = new CCSprite("grossini_dance_04.png");
            sprite4.Position = (new CCPoint(0, 0));
            sprite4.Scale = 0.5f;

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, -2);
            sprite1.AddChild(sprite4, 3);

            point = new CCSprite("Images/r1");
            point.Scale = 0.25f;
            point.Position = sprite1.Position;
            AddChild(point, 10);

            // anchor (0.5, 0.5)
            sprite1 = new CCSprite("grossini_dance_08.png");
            sprite1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            sprite1.AnchorPoint = (new CCPoint(0.5f, 0.5f));

            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite2.Position = (new CCPoint(20, 30));

            sprite3 = new CCSprite("grossini_dance_03.png");
            sprite3.Position = (new CCPoint(-20, 30));

            sprite4 = new CCSprite("grossini_dance_04.png");
            sprite4.Position = (new CCPoint(0, 0));
            sprite4.Scale = 0.5f;

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, -2);
            sprite1.AddChild(sprite4, 3);

            point = new CCSprite("Images/r1");
            point.Scale = 0.25f;
            point.Position = sprite1.Position;
            AddChild(point, 10);

            // anchor (1,1)
            sprite1 = new CCSprite("grossini_dance_08.png");
            sprite1.Position = (new CCPoint(s.Width / 2 + s.Width / 4, s.Height / 2));
            sprite1.AnchorPoint = new CCPoint(1, 1);

            sprite2 = new CCSprite("grossini_dance_02.png");
            sprite2.Position = (new CCPoint(20, 30));

            sprite3 = new CCSprite("grossini_dance_03.png");
            sprite3.Position = (new CCPoint(-20, 30));

            sprite4 = new CCSprite("grossini_dance_04.png");
            sprite4.Position = (new CCPoint(0, 0));
            sprite4.Scale = 0.5f;

            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2, -2);
            sprite1.AddChild(sprite3, -2);
            sprite1.AddChild(sprite4, 3);

            point = new CCSprite("Images/r1");
            point.Scale = 0.25f;
            point.Position = sprite1.Position;
            AddChild(point, 10);
        }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:91,代码来源:SpriteChildrenAnchorPoint.cs

示例12: initWithSubTest

        public void initWithSubTest(int nSubTest, CCNode p)
        {
            subtestNumber = nSubTest;
            parent = p;
            batchNode = null;
            /*
            * Tests:
            * 1: 1 (32-bit) PNG sprite of 52 x 139
            * 2: 1 (32-bit) PNG Batch Node using 1 sprite of 52 x 139
            * 3: 1 (16-bit) PNG Batch Node using 1 sprite of 52 x 139
            * 4: 1 (4-bit) PVRTC Batch Node using 1 sprite of 52 x 139

            * 5: 14 (32-bit) PNG sprites of 85 x 121 each
            * 6: 14 (32-bit) PNG Batch Node of 85 x 121 each
            * 7: 14 (16-bit) PNG Batch Node of 85 x 121 each
            * 8: 14 (4-bit) PVRTC Batch Node of 85 x 121 each

            * 9: 64 (32-bit) sprites of 32 x 32 each
            *10: 64 (32-bit) PNG Batch Node of 32 x 32 each
            *11: 64 (16-bit) PNG Batch Node of 32 x 32 each
            *12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each
            */

            // purge textures
            CCTextureCache mgr = CCTextureCache.SharedTextureCache;
            //		[mgr removeAllTextures];
            mgr.RemoveTexture(mgr.AddImage("Images/grossinis_sister1"));
            mgr.RemoveTexture(mgr.AddImage("Images/grossini_dance_atlas"));
            mgr.RemoveTexture(mgr.AddImage("Images/spritesheet1"));

            switch (subtestNumber)
            {
                case 1:
                case 4:
                case 7:
                    break;

                case 2:
                    CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888;
                    batchNode = CCSpriteBatchNode.Create("Images/grossinis_sister1", 100);
                    p.AddChild(batchNode, 0);
                    break;

                case 3:
                    CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444;
                    batchNode = CCSpriteBatchNode.Create("Images/grossinis_sister1", 100);
                    p.AddChild(batchNode, 0);
                    break;

                case 5:
                    CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888;
                    batchNode = CCSpriteBatchNode.Create("Images/grossini_dance_atlas", 100);
                    p.AddChild(batchNode, 0);
                    break;

                case 6:
                    CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444;
                    batchNode = CCSpriteBatchNode.Create("Images/grossini_dance_atlas", 100);
                    p.AddChild(batchNode, 0);
                    break;

                    ///
                case 8:
                    CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888;
                    batchNode = CCSpriteBatchNode.Create("Images/spritesheet1", 100);
                    p.AddChild(batchNode, 0);
                    break;
                case 9:
                    CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444;
                    batchNode = CCSpriteBatchNode.Create("Images/spritesheet1", 100);
                    p.AddChild(batchNode, 0);
                    break;

                default:
                    break;
            }

            //if (batchNode != null)
            //{
            //    batchNode.retain();
            //}

            CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_Default;
        }
开发者ID:eickegao,项目名称:cocos2d-xna,代码行数:84,代码来源:SubTest.cs


注:本文中的cocos2d.CCNode.AddChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。