Exemplo n.º 1
0
 public override void Update(float dt)
 {
     elapsed += dt;
     if (elapsed > 1f)
     {
         elapsed = 0f;
         // CCLabelBMFont
         if (label1 != null)
         {
             RemoveChild(label1);
         }
         CCNode node = new CCNode();
         CCSize s    = CCDirector.SharedDirector.WinSize;
         float  x    = s.Width * CCMacros.CCRandomBetween0And1();
         float  y    = s.Height * CCMacros.CCRandomBetween0And1();
         label1 = new CCLabelBMFont(string.Format("{0:N2},{1:N2} @ Mem Leak Ctor", x, y), "fonts/konqa32.fnt", 255f, CCTextAlignment.Right, CCPoint.Zero);
         node.AddChild(label1);
         label1.Position = new CCPoint(x, y);
         AddChild(node);
         label1 = node;
         // Start - test case for memory leak mentioned at https://cocos2dxna.codeplex.com/discussions/544032
         node.Scale = 2f;
         //--> This action causes the leak
         CCScaleTo    acScale   = new CCScaleTo(0.1f, 1);
         CCDelayTime  acShow    = new CCDelayTime(0.1f);
         CCSplitRows  acFadeOut = new CCSplitRows(0.1f, 20);
         CCRemoveSelf acRemove  = new CCRemoveSelf(true);
         CCSequence   seq       = new CCSequence(acScale, acShow, acFadeOut, acRemove);
         node.RunAction(seq);
     }
 }
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var s = Layer.VisibleBoundsWorldspace.Size;

            for (int i = 0; i < 100; i++)
            {
                var p = new CCPoint(CCMacros.CCRandomBetween0And1() * s.Width, CCMacros.CCRandomBetween0And1() * s.Height);
                this[i + 100].Position = p;
            }
        }
        void ClearImage(object sender)
        {
            canvasNode.Clear();
            RemoveChildByTag(spriteTag);

            Color = new CCColor3B((byte)(CCMacros.CCRandomBetween0And1() * 255), (byte)(CCMacros.CCRandomBetween0And1() * 255),
                                  (byte)(CCMacros.CCRandomBetween0And1() * 255));

            while (Opacity < 127)
            {
                Opacity = (byte)(CCMacros.CCRandomBetween0And1() * 255);
            }
        }
Exemplo n.º 4
0
        public override void TouchEnded(CCTouch touch)
        {
            base.TouchEnded(touch);
            CCLightning node = (CCLightning)GetChildByTag(55);

            node.AddBolt(new CCLightningBolt()
            {
                BoltColor     = CCLightning.LightningBlue,
                BoltGlowColor = CCLightning.LightningBlue,
                Start         = CCDirector.SharedDirector.WinSize.Center,
                End           = ConvertToNodeSpace(touch.Location),
                StrikeTime    = (2f * CCMacros.CCRandomBetween0And1()),
                FadeTime      = 0.15f,
                Width         = .5f
            });
        }
Exemplo n.º 5
0
 public override void Update(float dt)
 {
     elapsed += dt;
     if (elapsed > 0.5f)
     {
         elapsed = 0f;
         // CCLabelBMFont
         if (label1 != null)
         {
             RemoveChild(label1);
         }
         CCSize s = CCDirector.SharedDirector.WinSize;
         float  x = s.Width * CCMacros.CCRandomBetween0And1();
         float  y = s.Height * CCMacros.CCRandomBetween0And1();
         label1 = new CCLabelBMFont(string.Format("{0:N2},{1:N2} @ MEMORY LEAK", x, y), "fonts/konqa32.fnt");
         AddChild(label1);
         label1.Position = new CCPoint(x, y);
     }
 }
Exemplo n.º 6
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var s = VisibleBoundsWorldspace.Size;

            var parent = new CCNode();

            parent.Position = new CCPoint(0, 0);
            AddChild(parent);

            for (int i = 0; i < 10000 / 3.9; ++i)
            {
                var sprite = new CCSprite("Images/grossini_dance_01.png");
                sprite.Scale    = 0.1f;
                sprite.Position = new CCPoint(CCMacros.CCRandomBetween0And1() * s.Width, CCMacros.CCRandomBetween0And1() * s.Height);
                parent.AddChild(sprite);
            }
        }
Exemplo n.º 7
0
        public AtlasFastBitmap()
        {
            // Upper Label
            for (int i = 0; i < 100; i++)
            {
                //char str[6] = {0};
                string str;
                //sprintf(str, "-%d-", i);
                str = string.Format("-{0}-", i);
                CCLabelBMFont label = new CCLabelBMFont(str, "fonts/bitmapFontTest.fnt");
                AddChild(label);

                CCSize s = CCDirector.SharedDirector.WinSize;

                CCPoint p = new CCPoint(CCMacros.CCRandomBetween0And1() * s.Width, CCMacros.CCRandomBetween0And1() * s.Height);
                label.Position    = p;
                label.AnchorPoint = new CCPoint(0.5f, 0.5f);
            }
        }
Exemplo n.º 8
0
        public override void TouchesBegan(List <CCTouch> touches)
        {
            foreach (CCTouch t in touches)
            {
                // ask director the the window size
                CCSize size = CCDirector.SharedDirector.WinSize;

                CCPoint           center   = new CCPoint(size.Width / 2, size.Height / 2);
                CCPoint           end      = t.Location;
                float             fadeTime = CCMacros.CCRandomBetween0And1() * 5f;
                CCLightningStreak s        = new CCLightningStreak(center, end, fadeTime, 15f, 4.0f, new CCColor3B(0, 0, 255), TestResource.s_fire);
                s.Duration = .5f;
                AddChild(s);
                var target = new CCParticleSun();
                target.Scale    = 0.2f;
                target.Position = end;
                AddChild(target);
                target.RunAction(new CCSequence(new CCFadeOut(fadeTime), new CCRemoveSelf()));
            }
        }
Exemplo n.º 9
0
        public void addNewSpriteWithCoords(CCPoint p)
        {
            int idx = (int)(CCMacros.CCRandomBetween0And1() * 1400.0f / 100.0f);
            int x   = (idx % 5) * 85;
            int y   = (idx / 5) * 121;

            CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(x, y, 85, 121));

            AddChild(sprite);

            sprite.Position = p;

            CCActionInterval action;
            float            random = CCMacros.CCRandomBetween0And1();

            if (random < 0.20)
            {
                action = new CCScaleBy(3, 2);
            }
            else if (random < 0.40)
            {
                action = new CCRotateBy(3, 360);
            }
            else if (random < 0.60)
            {
                action = new CCBlink(1, 3);
            }
            else if (random < 0.8)
            {
                action = new CCTintBy(2, 0, -255, -255);
            }
            else
            {
                action = new CCFadeOut(2);
            }
            object           obj         = action.Reverse();
            CCActionInterval action_back = (CCActionInterval)action.Reverse();
            CCActionInterval seq         = (CCActionInterval)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever(seq));
        }
Exemplo n.º 10
0
 public override void Update(float dt)
 {
     elapsed += dt;
     if (elapsed > 0.5f)
     {
         elapsed = 0f;
         // CCLabelBMFont
         if (label1 != null)
         {
             RemoveChild(label1);
         }
         CCNode node = new CCNode();
         CCSize s    = CCDirector.SharedDirector.WinSize;
         float  x    = s.Width * CCMacros.CCRandomBetween0And1();
         float  y    = s.Height * CCMacros.CCRandomBetween0And1();
         label1 = new CCLabelBMFont(string.Format("{0:N2},{1:N2} @ Mem Leak Ctor", x, y), "fonts/konqa32.fnt", 255f, CCTextAlignment.Right, CCPoint.Zero);
         node.AddChild(label1);
         label1.Position = new CCPoint(x, y);
         AddChild(node);
         label1 = node;
     }
 }
Exemplo n.º 11
0
        public ParallaxScrollTest()
        {
            CCSize screen = CCDirector.SharedDirector.WinSize;

            parallax = new CCParallaxScrollNode();
            CCSprite land1 = new CCSprite("Images/land_green");
            CCSprite land2 = new CCSprite("Images/land_green");

            parallax.AddInfiniteScrollXWithZ(0, new CCPoint(0.5f, 0.2f), CCPoint.Zero, new CCSprite[] { land1, land2 });

            CCSprite land3 = new CCSprite("Images/land_grey");
            CCSprite land4 = new CCSprite("Images/land_grey");

            parallax.AddInfiniteScrollXWithZ(-2, new CCPoint(0.05f, 0.2f), new CCPoint(0f, 60f), new CCSprite[] { land3, land4 });

            CCSprite clouds1 = new CCSprite("Images/clouds");
            CCSprite clouds2 = new CCSprite("Images/clouds");

            parallax.AddInfiniteScrollXWithZ(1, new CCPoint(0.1f, 0.1f), new CCPoint(0f, screen.Height - clouds1.ContentSize.Height), new CCSprite[] { clouds1, clouds2 });

            for (int i = 0; i < 10; i++)
            {
                CCSprite mountain = new CCSprite("Images/mountain_grey");
                CCPoint  pos      = new CCPoint(CCMacros.CCRandomBetween0And1() * land1.ContentSize.Width * 2f, (0.1f + 0.24f * CCMacros.CCRandomBetween0And1()) * screen.Height);

                float speedMountainX = 0.15f + CCMacros.CCRandomBetween0And1() * 0.1f;
                parallax.AddChild(mountain, -1, new CCPoint(speedMountainX, .015f), pos, new CCPoint(land1.ContentSize.Width * 2f, 0));

                mountain.Scale = 0.6f + CCMacros.CCRandomBetween0And1() * 0.4f;
            }

            CCSprite sky = new CCSprite("Images/sky_evening");

            sky.AnchorPoint = CCPoint.AnchorLowerLeft;
            AddChild(parallax);
            AddChild(sky, -1);
        }
Exemplo n.º 12
0
 public void clearImage(object pSender)
 {
     m_pTarget.Clear(CCMacros.CCRandomBetween0And1(), CCMacros.CCRandomBetween0And1(), CCMacros.CCRandomBetween0And1(), CCMacros.CCRandomBetween0And1());
 }
Exemplo n.º 13
0
 void ClearImage(object sender)
 {
     target.Clear(CCMacros.CCRandomBetween0And1(), CCMacros.CCRandomBetween0And1(),
                  CCMacros.CCRandomBetween0And1(), CCMacros.CCRandomBetween0And1());
 }
Exemplo n.º 14
0
 void ClearImage(object sender)
 {
     target.BeginWithClear((byte)(CCMacros.CCRandomBetween0And1() * 255), (byte)(CCMacros.CCRandomBetween0And1() * 255),
                           (byte)(CCMacros.CCRandomBetween0And1() * 255), (byte)(CCMacros.CCRandomBetween0And1() * 255));
     target.End();
 }