Ejemplo n.º 1
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = CCDirector.SharedDirector.WinSize;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            CCLog.Log("S9BatchNodeBasic ...");

            var batchNode = new CCSpriteBatchNode("Images/blocks9.png");

            //batchNode.AnchorPoint = new CCPoint(0.5f, 0.5f);
            CCLog.Log("batchNode created with : Images/blocks9.png");

            var blocks = new CCScale9Sprite();

            CCLog.Log("... created");

            blocks.UpdateWithBatchNode(batchNode, new CCRect(0, 0, 96, 96), false, new CCRect(0, 0, 96, 96));
            CCLog.Log("... updateWithBatchNode");

            blocks.Position = new CCPoint(x, y);
            CCLog.Log("... setPosition");

            AddChild(blocks);
            CCLog.Log("AddChild");

            CCLog.Log("... S9BatchNodeBasic done.");
        }
Ejemplo n.º 2
0
        public TMXOrthoTest2()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test1");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

            CCSize s = map.contentSize;
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            List <CCNode>     pChildrenArray = map.children;
            CCSpriteBatchNode child          = null;
            CCObject          pObject        = null;

            if (pChildrenArray != null && pChildrenArray.Count > 0)
            {
                for (int i = 0; i < pChildrenArray.Count; i++)
                {
                    pObject = pChildrenArray[i];
                    child   = (CCSpriteBatchNode)pObject;

                    if (child == null)
                    {
                        break;
                    }

                    //child.Texture.setAntiAliasTexParameters();
                }
            }
            map.runAction(CCScaleBy.actionWithDuration(2, 0.5f));
        }
Ejemplo n.º 3
0
 public void ProcessSprite(CCSpriteBatchNode sprite)
 {
     //sprite.BlendFunc = new CCBlendFunc(blendSrc, blendDst);
     //sprite.IsAntialiased = true;
     //sprite.IsOpacityModifyRGB = true;
     //sprite.
 }
Ejemplo n.º 4
0
        public SpriteBatchNodeZVertex()
        {
            //
            // 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.
            //

            // small capacity. Testing resizing.
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);
            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            sprites = new CCSprite[numOfSprites];

            for (int i = 0; i < 5; i++)
            {
                sprites[i]         = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
                sprites[i].VertexZ = (10 + i * 40);
                batch.AddChild(sprites[i], 0);
            }

            for (int i = 5; i < 11; i++)
            {
                sprites[i]         = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 0, 85, 121));
                sprites[i].VertexZ = 10 + (10 - i) * 40;
                batch.AddChild(sprites[i], 0);
            }
        }
        public GameLayer()
        {
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = OnTouchesEnded;

            Color   = new CCColor3B(CCColor4B.White);
            Opacity = 255;

            // batch node for physics balls
            ballsBatch  = new CCSpriteBatchNode("balls", 100);
            ballTexture = ballsBatch.Texture;
            AddChild(ballsBatch, 1, 1);

            visibleBananas = new List <CCSprite>();
            hitBananas     = new List <CCSprite>();

            Schedule(t =>
            {
                visibleBananas.Add(AddBanana());
                elapsedTime += t;
                if (ShouldEndGame())
                {
                    EndGame();
                }
            }, 1.0f);

            Schedule(t => CheckCollision());

            AddGrass();
            AddSun();
            AddMonkey();
        }
Ejemplo n.º 6
0
        public SpriteBatchNodeZOrder()
        {
            dir = 1;

            // small capacity. Testing resizing.
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);

            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            sprites = new CCSprite[numOfSprites];

            for (int i = 0; i < 5; i++)
            {
                sprites[i] = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
                batch.AddChild(sprites[i], i);
            }

            for (int i = 5; i < 10; i++)
            {
                sprites[i] = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 0, 85, 121));
                batch.AddChild(sprites[i], 14 - i);
            }

            sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 3, 121 * 0, 85, 121));
            batch.AddChild(sprite1, -1, (int)kTagSprite.kTagSprite1);
            sprite1.Scale = 6;
            sprite1.Color = CCColor3B.Red;
        }
Ejemplo n.º 7
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = CCDirector.SharedDirector.WinSize;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            CCLog.Log("S9BatchNodeScaleWithCapInsets ...");

            var batchNode_scaled_with_insets = new CCSpriteBatchNode("Images/blocks9.png");

            CCLog.Log("batchNode_scaled_with_insets created with : Images/blocks9.png");

            var blocks_scaled_with_insets = new CCScale9Sprite();

            CCLog.Log("... created");

            blocks_scaled_with_insets.UpdateWithBatchNode(batchNode_scaled_with_insets, new CCRect(0, 0, 96, 96), false,
                                                          new CCRect(32, 32, 32, 32));
            CCLog.Log("... updateWithBatchNode");

            blocks_scaled_with_insets.ContentSize = new CCSize(96 * 4.5f, 96 * 2.5f);
            CCLog.Log("... setContentSize");

            blocks_scaled_with_insets.Position = new CCPoint(x, y);
            CCLog.Log("... setPosition");

            AddChild(blocks_scaled_with_insets);
            CCLog.Log("AddChild");

            CCLog.Log("... S9BatchNodeScaleWithCapInsets done.");
        }
Ejemplo n.º 8
0
        public SpriteBatchNodeAliased()
        {
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 10);

            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSprite sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));

            sprite1.Position = (new CCPoint(s.Width / 2 - 100, s.Height / 2));
            batch.AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1);

            CCSprite sprite2 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));

            sprite2.Position = (new CCPoint(s.Width / 2 + 100, s.Height / 2));
            batch.AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2);

            CCActionInterval scale      = new CCScaleBy(2, 5);
            CCActionInterval scale_back = (CCActionInterval)scale.Reverse();
            CCActionInterval seq        = (CCActionInterval)(CCSequence.FromActions(scale, scale_back));
            CCAction         repeat     = new CCRepeatForever(seq);

            CCAction repeat2 = (CCAction)(repeat.Copy());

            sprite1.RunAction(repeat);
            sprite2.RunAction(repeat2);
        }
Ejemplo n.º 9
0
        public SpriteFrameAliasNameTest()
        {
            CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;

            cache.AddSpriteFrames("animations/grossini-aliases.plist", "animations/grossini-aliases");

            var    animFrames = new List <CCSpriteFrame>(15);
            string str        = "";

            for (int i = 1; i < 15; i++)
            {
                // Obtain frames by alias name
                str = string.Format("dance_{0:00}", i);
                CCSpriteFrame frame = cache[str];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.3f);

            sprite = new CCSprite("grossini_dance_01.png");

            CCSpriteBatchNode spriteBatch = new CCSpriteBatchNode("animations/grossini-aliases");

            spriteBatch.AddChild(sprite);
            AddChild(spriteBatch);
        }
Ejemplo n.º 10
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            CCLog.Log("S9BatchNodeScaledNoInsets ...");

            // scaled without insets
            var batchNode_scaled = new CCSpriteBatchNode("Images/blocks9.png");

            CCLog.Log("batchNode_scaled created with : Images/blocks9.png");

            var blocks_scaled = new CCScale9Sprite();

            CCLog.Log("... created");
            blocks_scaled.UpdateWithBatchNode(batchNode_scaled, new CCRect(0, 0, 96, 96), false,
                                              new CCRect(0, 0, 96, 96));
            CCLog.Log("... updateWithBatchNode");

            blocks_scaled.Position = new CCPoint(x, y);
            CCLog.Log("... setPosition");

            blocks_scaled.ContentSize = new CCSize(96 * 4, 96 * 2);
            CCLog.Log("... setContentSize");

            AddChild(blocks_scaled);
            CCLog.Log("AddChild");

            CCLog.Log("... S9BtchNodeScaledNoInsets done.");
        }
Ejemplo n.º 11
0
        public GameLayer()
        {
            var touchListener = new CCEventListenerTouchAllAtOnce();

            touchListener.OnTouchesEnded = OnTouchesEnded;

            AddEventListener(touchListener, this);
            Color   = new CCColor3B(CCColor4B.White);
            Opacity = 255;

            visibleBananas = new List <CCSprite>();
            hitBananas     = new List <CCSprite>();

            // batch node for physics balls
            ballsBatch  = new CCSpriteBatchNode("balls", 100);
            ballTexture = ballsBatch.Texture;
            AddChild(ballsBatch, 1, 1);

            AddGrass();
            AddSun();
            AddMonkey();

            StartScheduling();

            CCSimpleAudioEngine.SharedEngine.PlayBackgroundMusic("Sounds/backgroundMusic", true);
        }
Ejemplo n.º 12
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSpriteBatchNode batch = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);

            batch.Texture.SetAliasTexParameters();
        }
Ejemplo n.º 13
0
        /// <summary>
        ///  Implement CCDirector and CCScene init code here.
        /// </summary>
        /// <returns>
        ///  true  Initialize success, app continue.
        ///  false Initialize failed, app terminate.
        /// </returns>
        public override bool ApplicationDidFinishLaunching()
        {
            //initialize director
            CCDirector pDirector = CCDirector.SharedDirector;

            pDirector.SetOpenGlView();


            // 2D projection
            pDirector.Projection = CCDirectorProjection.Projection2D;

            var resPolicy = CCResolutionPolicy.ExactFit; // This will stretch out your game

            CCDrawManager.SetDesignResolutionSize(preferredWidth,
                                                  preferredHeight,
                                                  resPolicy);

            // turn on display FPS
            //pDirector.DisplayStats = true;

            // set FPS. the default value is 1.0/60 if you don't call this
            pDirector.AnimationInterval = 1.0 / 60;

            GameSpriteBatchNode = new CCSpriteBatchNode("sprites/player_sprite_texture.png");

            CCScene pScene = StartGameScene.Scene();

            pDirector.RunWithScene(pScene);
            return(true);
        }
        public SpriteBatchNodeReorderIssue767()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            string   scope = CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/ghosts.plist", "animations/ghosts");
            CCNode   aParent;
            CCSprite l1, l2a, l2b, l3a1, l3a2, l3b1, l3b2;

            //
            // SpriteBatchNode: 3 levels of children
            //
            aParent = new CCSpriteBatchNode("animations/ghosts");
            AddChild(aParent, 0, (int)kTagSprite.kTagSprite1);

            // parent
            l1          = new CCSprite(scope + "father.gif");
            l1.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            aParent.AddChild(l1, 0, (int)kTagSprite.kTagSprite2);
            CCSize l1Size = l1.ContentSize;

            // child left
            l2a          = new CCSprite(scope + "sister1.gif");
            l2a.Position = (new CCPoint(-25 + l1Size.Width / 2, 0 + l1Size.Height / 2));
            l1.AddChild(l2a, -1, (int)kTags.kTagSpriteLeft);
            CCSize l2aSize = l2a.ContentSize;


            // child right
            l2b          = new CCSprite(scope + "sister2.gif");
            l2b.Position = (new CCPoint(+25 + l1Size.Width / 2, 0 + l1Size.Height / 2));
            l1.AddChild(l2b, 1, (int)kTags.kTagSpriteRight);
            CCSize l2bSize = l2a.ContentSize;


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

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

            // child right bottom
            l3b1          = new CCSprite(scope + "child1.gif");
            l3b1.Scale    = (0.65f);
            l3b1.Position = (new CCPoint(0 + l2bSize.Width / 2, -50 + l2bSize.Height / 2));
            l2b.AddChild(l3b1, -1);

            // child right top
            l3b2          = new CCSprite(scope + "child1.gif");
            l3b2.Scale    = (0.65f);
            l3b2.Position = (new CCPoint(0 + l2bSize.Width / 2, +50 + l2bSize.Height / 2));
            l2b.AddChild(l3b2, 1);

            Schedule(reorderSprites, 1);
        }
Ejemplo n.º 15
0
        public SpriteBatchNodeAliased()
        {
            CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 10);

            addChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCSprite sprite1 = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));

            sprite1.position = (new CCPoint(s.width / 2 - 100, s.height / 2));
            batch.addChild(sprite1, 0, (int)kTagSprite.kTagSprite1);

            CCSprite sprite2 = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));

            sprite2.position = (new CCPoint(s.width / 2 + 100, s.height / 2));
            batch.addChild(sprite2, 0, (int)kTagSprite.kTagSprite2);

            CCActionInterval scale      = CCScaleBy.actionWithDuration(2, 5);
            CCActionInterval scale_back = (CCActionInterval)scale.reverse();
            CCActionInterval seq        = (CCActionInterval)(CCSequence.actions(scale, scale_back));
            CCAction         repeat     = CCRepeatForever.actionWithAction(seq);

            CCAction repeat2 = (CCAction)(repeat.copy());

            sprite1.runAction(repeat);
            sprite2.runAction(repeat2);
        }
        public override void OnEnter()
        {
            base.OnEnter();
            CCSpriteBatchNode batch = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);

            batch.IsAntialiased = false;
        }
Ejemplo n.º 17
0
        public Box2DTestLayer()
        {
            TouchEnabled         = true;
            AccelerometerEnabled = true;
            CCSize s = CCDirector.SharedDirector.WinSize;

            // init physics
            initPhysics();
            // create reset button
            createResetButton();

            //Set up sprite
            // Use batch node. Faster
            _batch           = new CCSpriteBatchNode("Images/blocks", 100);
            m_pSpriteTexture = _batch.Texture;
            AddChild(_batch, 0, kTagParentNode);

            addNewSpriteAtPosition(new CCPoint(s.Width / 2, s.Height / 2));

            CCLabelTTF label = new CCLabelTTF("Tap screen", "MarkerFelt", 32);

            AddChild(label, 0);
            label.Color    = new CCColor3B(0, 0, 255);
            label.Position = new CCPoint(s.Width / 2, s.Height - 50);

            ScheduleUpdate();
        }
        public SpriteBatchNodeReorderIssue767()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/ghosts", "animations/images/ghosts");
            CCNode   aParent;
            CCSprite l1, l2a, l2b, l3a1, l3a2, l3b1, l3b2;

            //
            // SpriteBatchNode: 3 levels of children
            //
            aParent = CCSpriteBatchNode.batchNodeWithFile("animations/images/ghosts");
            addChild(aParent, 0, (int)kTagSprite.kTagSprite1);

            // parent
            l1          = CCSprite.spriteWithSpriteFrameName("father.gif");
            l1.position = (new CCPoint(s.width / 2, s.height / 2));
            aParent.addChild(l1, 0, (int)kTagSprite.kTagSprite2);
            CCSize l1Size = l1.contentSize;

            // child left
            l2a          = CCSprite.spriteWithSpriteFrameName("sister1.gif");
            l2a.position = (new CCPoint(-25 + l1Size.width / 2, 0 + l1Size.height / 2));
            l1.addChild(l2a, -1, (int)kTags.kTagSpriteLeft);
            CCSize l2aSize = l2a.contentSize;

            // child right
            l2b          = CCSprite.spriteWithSpriteFrameName("sister2.gif");
            l2b.position = new CCPoint(+25 + l1Size.width / 2, 0 + l1Size.height / 2);
            l1.addChild(l2b, 1, (int)kTags.kTagSpriteRight);
            CCSize l2bSize = l2a.contentSize;


            // child left bottom
            l3a1          = CCSprite.spriteWithSpriteFrameName("child1.gif");
            l3a1.scale    = 0.65f;
            l3a1.position = new CCPoint(0 + l2aSize.width / 2, -50 + l2aSize.height / 2);
            l2a.addChild(l3a1, -1);

            // child left top
            l3a2          = CCSprite.spriteWithSpriteFrameName("child1.gif");
            l3a2.scale    = 0.65f;
            l3a2.position = (new CCPoint(0 + l2aSize.width / 2, +50 + l2aSize.height / 2));
            l2a.addChild(l3a2, 1);

            // child right bottom
            l3b1          = CCSprite.spriteWithSpriteFrameName("child1.gif");
            l3b1.scale    = 0.65f;
            l3b1.position = (new CCPoint(0 + l2bSize.width / 2, -50 + l2bSize.height / 2));
            l2b.addChild(l3b1, -1);

            // child right top
            l3b2          = CCSprite.spriteWithSpriteFrameName("child1.gif");
            l3b2.scale    = 0.65f;
            l3b2.position = (new CCPoint(0 + l2bSize.width / 2, +50 + l2bSize.height / 2));
            l2b.addChild(l3b2, 1);

            schedule(reorderSprites, 1);
        }
Ejemplo n.º 19
0
        public override void OnExit()
        {
            // restore the tex parameter to AntiAliased.
            CCSpriteBatchNode batch = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);

            batch.Texture.SetAntiAliasTexParameters();
            base.OnExit();
        }
Ejemplo n.º 20
0
 public Box2DTestLayer()
 {
     //Set up sprite
     // Use batch node. Faster
     _batch           = new CCSpriteBatchNode("Images/blocks", 100);
     m_pSpriteTexture = _batch.Texture;
     AddChild(_batch, 0, kTagParentNode);
 }
        public override void OnExit()
        {
            // restore the tex parameter to AntiAliased.
            CCSpriteBatchNode batch = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);

            batch.IsAntialiased = true;
            base.OnExit();
        }
        public void removeAndAddSprite(float dt)
        {
            CCSpriteBatchNode batch  = (CCSpriteBatchNode)(GetChildByTag((int)kTags.kTagSpriteBatchNode));
            CCSprite          sprite = (CCSprite)(batch.GetChildByTag((int)kTagSprite.kTagSprite5));

            batch.RemoveChild(sprite, false);
            batch.AddChild(sprite, 0, (int)kTagSprite.kTagSprite5);
        }
Ejemplo n.º 23
0
        public SpriteBatchNodeOffsetAnchorSkewScale()
        {
            CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;

            cache.AddSpriteFrames("animations/grossini.plist");
            cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray");

            // Create animations and actions

            var    animFrames = new List <CCSpriteFrame>();
            string tmp        = "";

            for (int j = 0; j < 14; j++)
            {
                string temp = "";
                if (j + 1 < 10)
                {
                    temp = "0" + (j + 1);
                }
                else
                {
                    temp = (j + 1).ToString();
                }
                tmp = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = cache[tmp];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.3f);

            // skew
            CCSkewBy           skewX      = new CCSkewBy(2, 45, 0);
            CCFiniteTimeAction skewX_back = (CCFiniteTimeAction)skewX.Reverse();
            CCSkewBy           skewY      = new CCSkewBy(2, 0, 45);
            CCFiniteTimeAction skewY_back = (CCFiniteTimeAction)skewY.Reverse();

            // scale
            CCScaleBy          scale      = new CCScaleBy(2, 2);
            CCFiniteTimeAction scale_back = (CCFiniteTimeAction)scale.Reverse();

            seq_scale = new CCSequence(scale, scale_back);
            seq_skew  = new CCSequence(skewX, skewX_back, skewY, skewY_back);

            sprites      = new CCSprite[numOfSprites];
            pointSprites = new CCSprite[numOfSprites];

            for (int i = 0; i < numOfSprites; i++)
            {
                // Animation using Sprite batch
                sprites[i]      = new CCSprite("grossini_dance_01.png");
                pointSprites[i] = new CCSprite("Images/r1");

                CCSpriteBatchNode spritebatch = new CCSpriteBatchNode("animations/grossini");
                AddChild(spritebatch);
                AddChild(pointSprites[i], 200);
                spritebatch.AddChild(sprites[i], i);
            }
        }
Ejemplo n.º 24
0
        public override void initWithQuantityOfNodes(int nNodes)
        {
            batchNode = new CCSpriteBatchNode("Images/spritesheet1");
            AddChild(batchNode);

            base.initWithQuantityOfNodes(nNodes);

            ScheduleUpdate();
        }
Ejemplo n.º 25
0
        public SpriteBatchNodeReorderIssue766()
        {
            batchNode = new CCSpriteBatchNode("Images/piece", 15);
            AddChild(batchNode, 1, 0);

            sprite1 = MakeSpriteZ(2);
            sprite2 = MakeSpriteZ(3);
            sprite3 = MakeSpriteZ(4);
        }
        public SpriteBatchNodeReorder()
        {
            List <Object>     a       = new List <Object>(10);
            CCSpriteBatchNode asmtest = CCSpriteBatchNode.batchNodeWithFile("animations/images/ghosts");

            for (int i = 0; i < 10; i++)
            {
                CCSprite s1 = CCSprite.spriteWithBatchNode(asmtest, new CCRect(0, 0, 50, 50));
                a.Add(s1);
                asmtest.addChild(s1, 10);
            }

            for (int i = 0; i < 10; i++)
            {
                if (i != 5)
                {
                    asmtest.reorderChild((CCNode)(a[i]), 9);
                }
            }

            int           prev     = -1;
            List <CCNode> children = asmtest.children;
            CCSprite      child;

            foreach (var item in children)
            {
                child = (CCSprite)item;
                if (child == null)
                {
                    break;
                }

                int currentIndex = child.atlasIndex;
                Debug.Assert(prev == currentIndex - 1, "Child order failed");
                ////----UXLOG("children %x - atlasIndex:%d", child, currentIndex);
                prev = currentIndex;
            }

            prev = -1;
            List <CCSprite> sChildren = asmtest.Descendants;

            foreach (var item in sChildren)
            {
                child = (CCSprite)item;
                if (child == null)
                {
                    break;
                }

                int currentIndex = child.atlasIndex;
                Debug.Assert(prev == currentIndex - 1, "Child order failed");
                ////----UXLOG("descendant %x - atlasIndex:%d", child, currentIndex);
                prev = currentIndex;
            }

            //a.release();       //memory leak : 2010-0415
        }
Ejemplo n.º 27
0
        public SpriteBatchNodeNewTexture()
        {
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 50);

            AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            texture1 = batch.Texture;
            texture2 = CCTextureCache.SharedTextureCache.AddImage("Images/grossini_dance_atlas-mono");
        }
        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);
        }
        public SpriteChildrenVisibility()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini");

            CCNode   aParent;
            CCSprite sprite1, sprite2, sprite3;

            //
            // SpriteBatchNode
            //
            // parents
            aParent          = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini", 50);
            aParent.position = (new CCPoint(s.width / 3, s.height / 2));
            addChild(aParent, 0);



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

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

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

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

            sprite1.runAction(CCBlink.actionWithDuration(5, 10));

            //
            // Sprite
            //
            aParent          = CCNode.node();
            aParent.position = (new CCPoint(2 * s.width / 3, s.height / 2));
            addChild(aParent, 0);

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

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

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

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

            sprite1.runAction(CCBlink.actionWithDuration(5, 10));
        }
Ejemplo n.º 30
0
        public SpriteBatchNodeReorder()
        {
            List <Object>     a       = new List <Object>(10);
            CCSpriteBatchNode asmtest = new CCSpriteBatchNode("animations/ghosts");

            for (int i = 0; i < 10; i++)
            {
                CCSprite s1 = new CCSprite(asmtest.Texture, new CCRect(0, 0, 50, 50));
                a.Add(s1);
                asmtest.AddChild(s1, 10);
            }

            for (int i = 0; i < 10; i++)
            {
                if (i != 5)
                {
                    asmtest.ReorderChild((CCNode)(a[i]), 9);
                }
            }

            int      prev     = -1;
            var      children = asmtest.Children;
            CCSprite child;

            foreach (var item in children)
            {
                child = (CCSprite)item;
                if (child == null)
                {
                    break;
                }

                int currentIndex = child.AtlasIndex;
                Debug.Assert(prev == currentIndex - 1, "Child order failed");
                ////----UXLOG("children %x - atlasIndex:%d", child, currentIndex);
                prev = currentIndex;
            }

            prev = -1;
            var sChildren = asmtest.Descendants;

            foreach (var item in sChildren)
            {
                child = (CCSprite)item;
                if (child == null)
                {
                    break;
                }

                int currentIndex = child.AtlasIndex;
                Debug.Assert(prev == currentIndex - 1, "Child order failed");
                ////----UXLOG("descendant %x - atlasIndex:%d", child, currentIndex);
                prev = currentIndex;
            }
        }