示例#1
0
        public override void OnEnter()
        {
            // todo : CCOrbitCamera hasn't been implement

            base.OnEnter();

            centerSprites(3);

            var orbit1  = new CCOrbitCamera(2, 1, 0, 0, 180, 0, 0);
            var action1 = CCSequence.FromActions(orbit1, orbit1.Reverse());

            var orbit2  = new CCOrbitCamera(2, 1, 0, 0, 180, -45, 0);
            var action2 = CCSequence.FromActions(orbit2, orbit2.Reverse());

            var orbit3  = new CCOrbitCamera(2, 1, 0, 0, 180, 90, 0);
            var action3 = CCSequence.FromActions(orbit3, orbit3.Reverse());

            m_kathia.RunAction(new CCRepeatForever(action1));
            m_tamara.RunAction(new CCRepeatForever(action2));
            m_grossini.RunAction(new CCRepeatForever(action3));

            var move      = new CCMoveBy(3, new CCPoint(100, -100));
            var move_back = move.Reverse();
            var seq       = CCSequence.FromActions(move, move_back);
            var rfe       = new CCRepeatForever(seq);

            m_kathia.RunAction(rfe);
            m_tamara.RunAction((CCAction)(rfe.Copy()));
            m_grossini.RunAction((CCAction)(rfe.Copy()));
        }
示例#2
0
        public Test6()
        {
            CCSprite sp1  = new CCSprite(TestResource.s_pPathSister1);
            CCSprite sp11 = new CCSprite(TestResource.s_pPathSister1);

            CCSprite sp2  = new CCSprite(TestResource.s_pPathSister2);
            CCSprite sp21 = new CCSprite(TestResource.s_pPathSister2);

            sp1.Position = (new CCPoint(100, 160));
            sp2.Position = (new CCPoint(380, 160));

            CCActionInterval rot = new CCRotateBy(2, 360);
            var      rot_back    = rot.Reverse() as CCActionInterval;
            CCAction forever1    = new CCRepeatForever((CCActionInterval)CCSequence.FromActions(rot, rot_back));
            var      forever11   = (CCAction)(forever1.Copy());

            var forever2  = (CCAction)(forever1.Copy());
            var forever21 = (CCAction)(forever1.Copy());

            AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
            sp1.AddChild(sp11);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);
            sp2.AddChild(sp21);

            sp1.RunAction(forever1);
            sp11.RunAction(forever11);
            sp2.RunAction(forever2);
            sp21.RunAction(forever21);

            Schedule(addAndRemove, 2.0f);
        }
示例#3
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);
        }
示例#4
0
        public Test5()
        {
            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);

            sp2 = new CCSprite(TestResource.s_pPathSister2);

            sp1.Position = (new CCPoint(100, 160));
            sp2.Position = (new CCPoint(380, 160));

            CCRotateBy rot      = new CCRotateBy(2, 360);
            var        rot_back = rot.Reverse() as CCActionInterval;
            CCAction   forever  = new CCRepeatForever((CCActionInterval) new CCSequence(rot, rot_back));

            forever2     = (CCAction)(forever.Copy());
            forever.Tag  = (101);
            forever2.Tag = (102);

            AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);

            RemoveChild(sp2, true);
            AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);

            // Sprite 1 should run and run
            // Sprite 2 should stop

            sp1.RunAction(forever);
            sp2.RunAction(forever2);

            // Experiment with removing sp2 and re-adding it after cleanup to reproduce an error in child management
//            ScheduleOnce(Stage2OfTest, 2.0f);
            Schedule(addAndRemove, 2.0f);
        }
示例#5
0
        public Atlas4()
        {
            m_time = 0;

            // Upper Label
            CCLabelBMFont label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");

            AddChild(label);

            CCSize s = CCDirector.SharedDirector.WinSize;

            label.Position    = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);


            CCSprite BChar = (CCSprite)label.GetChildByTag(0);
            CCSprite FChar = (CCSprite)label.GetChildByTag(7);
            CCSprite AChar = (CCSprite)label.GetChildByTag(12);


            CCActionInterval rotate    = new CCRotateBy(2, 360);
            CCAction         rot_4ever = new CCRepeatForever(rotate);

            CCActionInterval   scale       = new CCScaleBy(2, 1.5f);
            CCFiniteTimeAction scale_back  = scale.Reverse();
            CCFiniteTimeAction scale_seq   = new CCSequence(scale, scale_back);
            CCAction           scale_4ever = new CCRepeatForever((CCActionInterval)scale_seq);

            CCActionInterval jump       = new CCJumpBy(0.5f, new CCPoint(), 60, 1);
            CCAction         jump_4ever = new CCRepeatForever(jump);

            CCActionInterval   fade_out   = new CCFadeOut(1);
            CCActionInterval   fade_in    = new CCFadeIn(1);
            CCFiniteTimeAction seq        = new CCSequence(fade_out, fade_in);
            CCAction           fade_4ever = new CCRepeatForever((CCActionInterval)seq);

            BChar.RunAction(rot_4ever);
            BChar.RunAction(scale_4ever);
            FChar.RunAction(jump_4ever);
            AChar.RunAction(fade_4ever);


            // Bottom Label
            CCLabelBMFont label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt");

            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.Position = new CCPoint(s.Width / 2.0f, 80);

            CCSprite lastChar = (CCSprite)label2.GetChildByTag(3);

            lastChar.RunAction((CCAction)(rot_4ever.Copy()));

            //schedule( schedule_selector(Atlas4::step), 0.1f);
            base.Schedule(step, 0.1f);
        }
示例#6
0
        public Atlas3()
        {
            m_time = 0;

            CCLayerColor col = new CCLayerColor(new CCColor4B(128, 128, 128, 255));

            AddChild(col, -10);

            CCLabelBMFont label1 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");

            // testing anchors
            label1.AnchorPoint = new CCPoint(0, 0);
            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            CCActionInterval   fade    = new CCFadeOut(1.0f);
            CCFiniteTimeAction fade_in = fade.Reverse();
            CCFiniteTimeAction seq     = new CCSequence(fade, fade_in);
            CCAction           repeat  = new CCRepeatForever((CCActionInterval)seq);

            label1.RunAction(repeat);


            // VERY IMPORTANT
            // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image)
            // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images
            // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
            CCLabelBMFont label2 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");

            // testing anchors
            label2.AnchorPoint = new CCPoint(0.5f, 0.5f);
            label2.Color       = ccRED;
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.RunAction((CCAction)(repeat.Copy()));

            CCLabelBMFont label3 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");

            // testing anchors
            label3.AnchorPoint = new CCPoint(1, 1);
            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);


            CCSize s = CCDirector.SharedDirector.WinSize;

            label1.Position = new CCPoint();
            label2.Position = new CCPoint(s.Width / 2, s.Height / 2);
            label3.Position = new CCPoint(s.Width, s.Height);

            base.Schedule(step);//:@selector(step:)];
        }
        public SpriteBatchNodeAnchorPoint()
        {
            // 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);

            CCSize s = CCDirector.SharedDirector.WinSize;


            CCActionInterval rotate = new CCRotateBy(10, 360);
            CCAction         action = new CCRepeatForever(rotate);

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2));

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

                switch (i)
                {
                case 0:
                    sprite.AnchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.AnchorPoint = (new CCPoint(0.5f, 0.5f));
                    break;

                case 2:
                    sprite.AnchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.Position = sprite.Position;

                CCAction copy = (CCAction)(action.Copy());
                sprite.RunAction(copy);
                batch.AddChild(sprite, i);
            }
        }
示例#8
0
        public Sprite6()
        {
            // 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, kTagSpriteBatchNode);
            batch.IgnoreAnchorPointForPosition = true;

            CCSize s = CCDirector.SharedDirector.WinSize;

            batch.AnchorPoint = new CCPoint(0.5f, 0.5f);
            batch.ContentSize = (new CCSize(s.Width, s.Height));


            // SpriteBatchNode actions
            CCActionInterval rotate = new CCRotateBy(5, 360);
            CCAction         action = new CCRepeatForever(rotate);

            // SpriteBatchNode actions
            CCActionInterval rotate_back    = (CCActionInterval)rotate.Reverse();
            CCActionInterval rotate_seq     = (CCActionInterval)(CCSequence.FromActions(rotate, rotate_back));
            CCAction         rotate_forever = new CCRepeatForever(rotate_seq);

            CCActionInterval scale         = new CCScaleBy(5, 1.5f);
            CCActionInterval scale_back    = (CCActionInterval)scale.Reverse();
            CCActionInterval scale_seq     = (CCActionInterval)(CCSequence.FromActions(scale, scale_back));
            CCAction         scale_forever = new CCRepeatForever(scale_seq);

            float step = s.Width / 4;

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));

                sprite.RunAction((CCAction)(action.Copy()));
                batch.AddChild(sprite, i);
            }

            batch.RunAction(scale_forever);
            batch.RunAction(rotate_forever);
        }
示例#9
0
        public SpriteAnchorPoint()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;


            CCActionInterval rotate = new CCRotateBy(10, 360);
            CCAction         action = new CCRepeatForever(rotate);

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * i, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2));

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

                switch (i)
                {
                case 0:
                    sprite.AnchorPoint = (new CCPoint(0, 0));
                    break;

                case 1:
                    sprite.AnchorPoint = (new CCPoint(0.5f, 0.5f));
                    break;

                case 2:
                    sprite.AnchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.Position = sprite.Position;

                CCAction copy = (CCAction)(action.Copy());
                sprite.RunAction(copy);
                AddChild(sprite, i);
            }
        }
示例#10
0
        public ConvertToNode()
        {
            TouchEnabled = true;
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCRotateBy      rotate = new CCRotateBy(10, 360);
            CCRepeatForever action = new CCRepeatForever(rotate);

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini");
                sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2));

                CCSprite point = new CCSprite("Images/r1");
                point.Scale    = 0.25f;
                point.Position = sprite.Position;
                AddChild(point, 10, 100 + i);

                switch (i)
                {
                case 0:
                    sprite.AnchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.AnchorPoint = (new CCPoint(0.5f, 0.5f));
                    break;

                case 2:
                    sprite.AnchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.Position = (sprite.Position);

                var copy = (CCRepeatForever)action.Copy();
                sprite.RunAction(copy);
                AddChild(sprite, i);
            }
        }
示例#11
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize s = CCDirector.SharedDirector.WinSize;

            //
            // Sprite 1: GL_LINEAR
            //
            // Default filter is GL_LINEAR

            CCSprite sprite = new CCSprite("Images/grossinis_sister1");

            sprite.Position = new CCPoint(s.Width / 3.0f, s.Height / 2.0f);
            AddChild(sprite);

            // this is the default filterting
            sprite.IsAntialiased = true;

            //
            // Sprite 1: GL_NEAREST
            //

            CCSprite sprite2 = new CCSprite("Images/grossinis_sister2");

            sprite2.Position = new CCPoint(2 * s.Width / 3.0f, s.Height / 2.0f);
            AddChild(sprite2);

            // Use Nearest in this one
            sprite2.IsAntialiased = false;

            // scale them to show
            CCScaleBy       sc           = new CCScaleBy(3, 8.0f);
            CCScaleBy       sc_back      = (CCScaleBy)(sc.Reverse());
            CCRepeatForever scaleforever = new CCRepeatForever((CCActionInterval)(new CCSequence(sc, sc_back)));
            CCRepeatForever scaleToo     = (CCRepeatForever)(scaleforever.Copy());

            sprite2.RunAction(scaleforever);
            sprite.RunAction(scaleToo);
            CCTextureCache.SharedTextureCache.DumpCachedTextureInfo();
        }
示例#12
0
        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);
        }
        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);
        }