コード例 #1
0
        public override void Update(float dt)
        {
            // reset seed
            //srandom(0);
            if (bTested)
            {
                return;
            }
            // 15 percent
            int totalToAdd = (int)(currentQuantityOfNodes * 0.15f);

            if (totalToAdd > 0)
            {
                List <CCSprite> sprites = new List <CCSprite>(totalToAdd);
                //int		 zs      = new int[totalToAdd];
                int[] zs = new int[totalToAdd];

                // Don't include the sprite creation time and random as part of the profiling
                long lStart = DateTime.Now.Ticks;
                for (int i = 0; i < totalToAdd; i++)
                {
                    CCSprite pSprite = new CCSprite(batchNode.Texture, new CCRect(0, 0, 32, 32));
                    sprites.Add(pSprite);
                    zs[i] = (int)(CCMacros.CCRandomBetweenNegative1And1() * 50);
                }
                long ldiff = DateTime.Now.Ticks - lStart;
                CCLog.Log("Add Sprite took {0} sec", (new TimeSpan(ldiff)).TotalSeconds);

                // add them with random Z (very important!)
                //#if CC_ENABLE_PROFILERS
                //        CCProfilingBeginTimingBlock(_profilingTimer);
                //#endif

                lStart = DateTime.Now.Ticks;
                for (int i = 0; i < totalToAdd; i++)
                {
                    batchNode.AddChild((CCNode)(sprites[i]), zs[i], PerformanceNodeChildrenTest.kTagBase + i);
                }
                ldiff = DateTime.Now.Ticks - lStart;
                CCLog.Log("Add Child to Batch took {0} sec", (new TimeSpan(ldiff)).TotalSeconds);

                //#if CC_ENABLE_PROFILERS
                //        CCProfilingEndTimingBlock(_profilingTimer);
                //#endif

                // remove them
                lStart = DateTime.Now.Ticks;
                for (int i = 0; i < totalToAdd; i++)
                {
                    batchNode.RemoveChildByTag(PerformanceNodeChildrenTest.kTagBase + i, true);
                }
                ldiff = DateTime.Now.Ticks - lStart;
                CCLog.Log("Remove Child took {0} sec", (new TimeSpan(ldiff)).TotalSeconds);
            }
            bTested = true;
        }
コード例 #2
0
        public override void Update(float dt)
        {
            if (bDone)
            {
                return;
            }
            //srandom(0);

            // 15 percent
            int totalToAdd = (int)(currentQuantityOfNodes * 0.15f);

            if (totalToAdd > 0)
            {
                List <CCSprite> sprites = new List <CCSprite>();

                // Don't include the sprite creation time as part of the profiling
                StartTimer();
                for (int i = 0; i < totalToAdd; i++)
                {
                    CCSprite pSprite = new CCSprite(batchNode.Texture, new CCRect(0, 0, 32, 32));
                    sprites.Add(pSprite);
                }
                EndTimer("Add " + totalToAdd + " sprites");

                // add them with random Z (very important!)
                StartTimer();
                for (int i = 0; i < totalToAdd; i++)
                {
                    batchNode.AddChild((CCNode)(sprites[i]), (int)(CCMacros.CCRandomBetweenNegative1And1() * 50), PerformanceNodeChildrenTest.kTagBase + i);
                }
                EndTimer("Add sprites to a batch node");

                // remove them
                //#if CC_ENABLE_PROFILERS
                //        CCProfilingBeginTimingBlock(_profilingTimer);
                //#endif

                StartTimer();
                for (int i = 0; i < totalToAdd; i++)
                {
                    batchNode.RemoveChildByTag(PerformanceNodeChildrenTest.kTagBase + i, true);
                }
                EndTimer("Remove children by tag from the batch node");

                //#if CC_ENABLE_PROFILERS
                //        CCProfilingEndTimingBlock(_profilingTimer);
                //#endif
            }
            bDone = true;
        }
コード例 #3
0
        public override void Update(float dt)
        {
            //srandom(0);

            // 15 percent
            int totalToAdd = (int)(currentQuantityOfNodes * 0.15f);

            if (totalToAdd > 0)
            {
                List <CCSprite> sprites = new List <CCSprite>();

                // Don't include the sprite creation time as part of the profiling
                for (int i = 0; i < totalToAdd; i++)
                {
                    CCSprite pSprite = new CCSprite(batchNode.Texture, new CCRect(0, 0, 32, 32));
                    sprites.Add(pSprite);
                }

                // add them with random Z (very important!)
                for (int i = 0; i < totalToAdd; i++)
                {
                    batchNode.AddChild((CCNode)(sprites[i]), (int)(CCMacros.CCRandomBetweenNegative1And1() * 50), PerformanceNodeChildrenTest.kTagBase + i);
                }

                //		[batchNode sortAllChildren];

                // reorder them
                //#if CC_ENABLE_PROFILERS
                //        CCProfilingBeginTimingBlock(_profilingTimer);
                //#endif

                for (int i = 0; i < totalToAdd; i++)
                {
                    CCNode node = (CCNode)(batchNode.Children[i]);
                    batchNode.ReorderChild(node, (int)(CCMacros.CCRandomBetweenNegative1And1() * 50));
                }

                //#if CC_ENABLE_PROFILERS
                //        CCProfilingEndTimingBlock(_profilingTimer);
                //#endif

                // remove them
                for (int i = 0; i < totalToAdd; i++)
                {
                    batchNode.RemoveChildByTag(PerformanceNodeChildrenTest.kTagBase + i, true);
                }
            }
        }