コード例 #1
0
        // CCLayer
        public override void onEnter()
        {
            base.onEnter();

            m_nCharLimit = 12;

            m_pTextFieldAction = CCRepeatForever.actionWithAction(
                (CCActionInterval)CCSequence.actions(
                    CCFadeOut.actionWithDuration(0.25f),
                    CCFadeIn.actionWithDuration(0.25f)));
            //m_pTextFieldAction->retain();
            m_bAction = false;

            // add CCTextFieldTTF
            CCSize s = CCDirector.sharedDirector().getWinSize();

            m_pTextField = CCTextFieldTTF.textFieldWithPlaceHolder("<click here for input>",
                                                                   TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            addChild(m_pTextField);

            //m_pTextField.setDelegate(this);


            //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
            //    // on android, CCTextFieldTTF cannot auto adjust its position when soft-keyboard pop up
            //    // so we had to set a higher position
            //    m_pTextField->setPosition(new CCPoint(s.width / 2, s.height/2 + 50));
            //#else
            //    m_pTextField->setPosition(ccp(s.width / 2, s.height / 2));
            //#endif

            m_pTrackNode = m_pTextField;
        }
コード例 #2
0
ファイル: NodeToWorld.cs プロジェクト: KogleDK/cocos2d-xna-1
        public NodeToWorld()
        {
            //
            // This code tests that nodeToParent works OK:
            //  - It tests different anchor Points
            //  - It tests different children anchor points

            CCSprite back = new CCSprite(TestResource.s_back3);
            AddChild(back, -10);
            back.AnchorPoint = (new CCPoint(0, 0));
            CCSize backSize = back.ContentSize;

            CCMenuItem item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
            CCMenu menu = new CCMenu(item);
            menu.AlignItemsVertically();
            menu.Position = (new CCPoint(backSize.Width / 2, backSize.Height / 2));
            back.AddChild(menu);

            CCActionInterval rot = new CCRotateBy (5, 360);
            CCAction fe = new CCRepeatForever (rot);
            item.RunAction(fe);

            CCActionInterval move = new CCMoveBy (3, new CCPoint(200, 0));
            var move_back = (CCActionInterval) move.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(move, move_back);
            CCAction fe2 = new CCRepeatForever ((CCActionInterval) seq);
            back.RunAction(fe2);
        }
コード例 #3
0
ファイル: CCRepeatForever.cs プロジェクト: liwq-net/liwq718
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone          tmpZone = zone;
            CCRepeatForever ret     = null;

            if (tmpZone != null && tmpZone.m_pCopyObject != null)
            {
                ret = tmpZone.m_pCopyObject as CCRepeatForever;
                if (ret == null)
                {
                    return(null);
                }
            }
            else
            {
                ret     = new CCRepeatForever();
                tmpZone = new CCZone(ret);
            }

            base.copyWithZone(tmpZone);

            CCActionInterval param = m_pInnerAction.copy() as CCActionInterval;

            if (param == null)
            {
                return(null);
            }
            ret.initWithAction(param);

            return(ret);
        }
コード例 #4
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone tmpZone = zone;
            CCRepeatForever ret = null;

            if (tmpZone != null && tmpZone.m_pCopyObject != null)
            {
                ret = tmpZone.m_pCopyObject as CCRepeatForever;
                if (ret == null)
                {
                    return null;
                }
            }
            else
            {
                ret = new CCRepeatForever();
                tmpZone = new CCZone(ret);
            }

            base.copyWithZone(tmpZone);

            CCActionInterval param = m_pInnerAction.copy() as CCActionInterval;
            if (param == null)
            {
                return null;
            }
            ret.initWithAction(param);

            return ret;
        }
コード例 #5
0
ファイル: Test6.cs プロジェクト: homocury/cocos2d-xna
        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);
        }
コード例 #6
0
        public static CCRepeatForever actionWithAction(CCActionInterval action)
        {
            CCRepeatForever ret = new CCRepeatForever();
            ret.initWithAction(action);

            return ret;
        }
コード例 #7
0
        public SpriteBatchNodeAliased()
        {
            CCSpriteBatchNode batch = CCSpriteBatchNode.Create("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);
        }
コード例 #8
0
        public static CCRepeatForever actionWithAction(CCActionInterval action)
        {
            CCRepeatForever cCRepeatForever = new CCRepeatForever();

            cCRepeatForever.initWithAction(action);
            return(cCRepeatForever);
        }
コード例 #9
0
        public override bool Init()
        {
            InitWithColor(new CCColor4B(0, 0, 255, 255));

            CCMenuItemFont item1 = CCMenuItemFont.Create("(3) Touch to pushScene (self)", item0Clicked);
            CCMenuItemFont item2 = CCMenuItemFont.Create("(3) Touch to popScene", item1Clicked);
            CCMenuItemFont item3 = CCMenuItemFont.Create("(3) Touch to popToRootScene", item2Clicked);

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

            AddChild(menu);

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCSprite sprite = new CCSprite(s_pPathGrossini);
            AddChild(sprite);

            sprite.Position = new CCPoint(s.Width /2, 40);
            CCActionInterval rotate = new CCRotateBy (2, 360);
            CCAction repeat = new CCRepeatForever (rotate);
            sprite.RunAction(repeat);

            Schedule(testDealloc);

            return true;
        }
コード例 #10
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone          cCZone          = zone;
            CCRepeatForever cCRepeatForever = null;

            if (cCZone == null || cCZone.m_pCopyObject == null)
            {
                cCRepeatForever = new CCRepeatForever();
                cCZone          = new CCZone(cCRepeatForever);
            }
            else
            {
                cCRepeatForever = cCZone.m_pCopyObject as CCRepeatForever;
                if (cCRepeatForever == null)
                {
                    return(null);
                }
            }
            base.copyWithZone(cCZone);
            CCActionInterval cCActionInterval = this.m_pInnerAction.copy() as CCActionInterval;

            if (cCActionInterval == null)
            {
                return(null);
            }
            cCRepeatForever.initWithAction(cCActionInterval);
            return(cCRepeatForever);
        }
コード例 #11
0
        public SpriteBatchNodeColorOpacity()
        {
            // 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);

            CCSprite sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
            CCSprite sprite2 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));
            CCSprite sprite3 = new CCSprite(batch.Texture, new CCRect(85 * 2, 121 * 1, 85, 121));
            CCSprite sprite4 = new CCSprite(batch.Texture, new CCRect(85 * 3, 121 * 1, 85, 121));

            CCSprite sprite5 = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
            CCSprite sprite6 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));
            CCSprite sprite7 = new CCSprite(batch.Texture, new CCRect(85 * 2, 121 * 1, 85, 121));
            CCSprite sprite8 = new CCSprite(batch.Texture, new CCRect(85 * 3, 121 * 1, 85, 121));

            CCSize s = CCDirector.SharedDirector.WinSize;
            sprite1.Position = new CCPoint((s.Width / 5) * 1, (s.Height / 3) * 1);
            sprite2.Position = new CCPoint((s.Width / 5) * 2, (s.Height / 3) * 1);
            sprite3.Position = new CCPoint((s.Width / 5) * 3, (s.Height / 3) * 1);
            sprite4.Position = new CCPoint((s.Width / 5) * 4, (s.Height / 3) * 1);
            sprite5.Position = new CCPoint((s.Width / 5) * 1, (s.Height / 3) * 2);
            sprite6.Position = new CCPoint((s.Width / 5) * 2, (s.Height / 3) * 2);
            sprite7.Position = new CCPoint((s.Width / 5) * 3, (s.Height / 3) * 2);
            sprite8.Position = new CCPoint((s.Width / 5) * 4, (s.Height / 3) * 2);

            CCActionInterval action = new CCFadeIn  (2);
            CCActionInterval action_back = (CCActionInterval)action.Reverse();
            CCAction fade = new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(action, action_back)));

            CCActionInterval tintred = new CCTintBy (2, 0, -255, -255);
            CCActionInterval tintred_back = (CCActionInterval)tintred.Reverse();
            CCAction red = new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(tintred, tintred_back)));

            CCActionInterval tintgreen = new CCTintBy (2, -255, 0, -255);
            CCActionInterval tintgreen_back = (CCActionInterval)tintgreen.Reverse();
            CCAction green = new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(tintgreen, tintgreen_back)));

            CCActionInterval tintblue = new CCTintBy (2, -255, -255, 0);
            CCActionInterval tintblue_back = (CCActionInterval)tintblue.Reverse();
            CCAction blue = new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(tintblue, tintblue_back)));

            sprite5.RunAction(red);
            sprite6.RunAction(green);
            sprite7.RunAction(blue);
            sprite8.RunAction(fade);

            // late add: test dirtyColor and dirtyPosition
            batch.AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1);
            batch.AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2);
            batch.AddChild(sprite3, 0, (int)kTagSprite.kTagSprite3);
            batch.AddChild(sprite4, 0, (int)kTagSprite.kTagSprite4);
            batch.AddChild(sprite5, 0, (int)kTagSprite.kTagSprite5);
            batch.AddChild(sprite6, 0, (int)kTagSprite.kTagSprite6);
            batch.AddChild(sprite7, 0, (int)kTagSprite.kTagSprite7);
            batch.AddChild(sprite8, 0, (int)kTagSprite.kTagSprite8);

            Schedule(removeAndAddSprite, 2);
        }
コード例 #12
0
        public static CCRepeatForever actionWithAction(CCActionInterval action)
        {
            CCRepeatForever ret = new CCRepeatForever();

            ret.initWithAction(action);

            return(ret);
        }
コード例 #13
0
        public Atlas4()
        {
            m_time = 0;

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

            addChild(label);

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

            label.position    = new CCPoint(s.width / 2, s.height / 2);
            label.anchorPoint = new CCPoint(0.5f, 0.5f);


            CCSprite BChar = (CCSprite)label.getChildByTag(1);
            CCSprite FChar = (CCSprite)label.getChildByTag(7);
            CCSprite AChar = (CCSprite)label.getChildByTag(12);


            CCActionInterval rotate    = CCRotateBy.actionWithDuration(2, 360);
            CCAction         rot_4ever = CCRepeatForever.actionWithAction(rotate);

            CCActionInterval scale = CCScaleBy.actionWithDuration(2, 1.5f);
            //CCActionInterval scale_back = scale.reverse();
            CCActionInterval   scale_back  = null;
            CCFiniteTimeAction scale_seq   = CCSequence.actions(scale, scale_back, null);
            CCAction           scale_4ever = CCRepeatForever.actionWithAction((CCActionInterval)scale_seq);

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

            CCActionInterval   fade_out   = CCFadeOut.actionWithDuration(1);
            CCActionInterval   fade_in    = CCFadeIn.actionWithDuration(1);
            CCFiniteTimeAction seq        = CCSequence.actions(fade_out, fade_in, null);
            CCAction           fade_4ever = CCRepeatForever.actionWithAction((CCActionInterval)seq);

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


            // Bottom Label
            CCLabelBMFont label2 = CCLabelBMFont.labelWithString("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);
        }
コード例 #14
0
ファイル: Atlas4.cs プロジェクト: eickegao/cocos2d-xna
        public Atlas4()
        {
            m_time = 0;

            // Upper Label
            CCLabelBMFont label = CCLabelBMFont.Create("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 = CCSequence.FromActions(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 = CCSequence.FromActions(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 = CCLabelBMFont.Create("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);
        }
コード例 #15
0
        private void performanceActions(CCSprite pSprite)
        {
            CCSize size = CCDirector.SharedDirector.WinSize;
            pSprite.Position = new CCPoint((Random.Next() % (int) size.Width), (Random.Next() % (int) size.Height));

            float period = 0.5f + (Random.Next() % 1000) / 500.0f;
            CCRotateBy rot = new CCRotateBy (period, 360.0f * Random.Float_0_1());
            var rot_back = rot.Reverse();
            CCAction permanentRotation = new CCRepeatForever (CCSequence.FromActions(rot, rot_back));
            pSprite.RunAction(permanentRotation);

            float growDuration = 0.5f + (Random.Next() % 1000) / 500.0f;
            CCActionInterval grow = new CCScaleBy(growDuration, 0.5f, 0.5f);
            CCAction permanentScaleLoop = new CCRepeatForever (new CCSequence (grow, grow.Reverse()));
            pSprite.RunAction(permanentScaleLoop);
        }
コード例 #16
0
        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);
        }
コード例 #17
0
        public LabelTTFA8Test()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer = CCLayerColor.Create(new CCColor4B(128, 128, 128, 255));
            AddChild(layer, -10);

            // CCLabelBMFont
            CCLabelTTF label1 = new CCLabelTTF("Testing A8 Format", "Marker Felt", 38);
            AddChild(label1);
            label1.Color = CCTypes.CCRed;
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);

            CCFadeOut fadeOut = new CCFadeOut  (2);
            CCFadeIn fadeIn = new CCFadeIn  (2);
            CCFiniteTimeAction seq = CCSequence.FromActions(fadeOut, fadeIn);
            CCRepeatForever forever = new CCRepeatForever ((CCActionInterval) seq);
            label1.RunAction(forever);
        }
コード例 #18
0
        public SceneTestLayer1()
        {
            CCMenuItemFont item1 = CCMenuItemFont.Create("(1) Test pushScene", onPushScene);
            CCMenuItemFont item2 = CCMenuItemFont.Create("(1) Test pushScene w/transition", onPushSceneTran);
            CCMenuItemFont item3 = CCMenuItemFont.Create("(1) Quit", onQuit);
            _PopMenuItem = CCMenuItemFont.Create("(1) Test popScene w/transition", onPopSceneTran);

            _TheMenu = new CCMenu(item1, item2, item3, _PopMenuItem);
            _TheMenu.AlignItemsVertically();

            AddChild(_TheMenu);

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCSprite sprite = new CCSprite(s_pPathGrossini);
            AddChild(sprite);
            sprite.Position = new CCPoint(s.Width - 40, s.Height / 2);
            CCActionInterval rotate = new CCRotateBy (2, 360);
            CCAction repeat = new CCRepeatForever (rotate);
            sprite.RunAction(repeat);
        }
コード例 #19
0
ファイル: Atlas3.cs プロジェクト: KogleDK/cocos2d-xna-1
        public Atlas3()
        {
            m_time = 0;

            CCLayerColor col = new CCLayerColor(new CCColor4B(128, 128, 128, 255));
            AddChild(col, -10);

            CCLabelBMFont label1 = CCLabelBMFont.Create("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 = CCSequence.FromActions(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 = CCLabelBMFont.Create("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 = CCLabelBMFont.Create("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:)];
        }
コード例 #20
0
ファイル: Sprite6.cs プロジェクト: homocury/cocos2d-xna
        public Sprite6()
        {
            // small capacity. Testing resizing
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = CCSpriteBatchNode.Create("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);
        }
コード例 #21
0
        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);
            }
        }
コード例 #22
0
        public LabelAtlasColorTest()
        {
            CCLabelAtlas label1 = CCLabelAtlas.Create("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.Position = new CCPoint(10, 100);
            label1.Opacity = 200;

            CCLabelAtlas label2 = CCLabelAtlas.Create("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.Position = new CCPoint(10, 200);
            label2.Color = ccRED;

            CCActionInterval fade = new CCFadeOut  (1.0f);
            CCFiniteTimeAction fade_in = fade.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in);
            CCAction repeat = new CCRepeatForever ((CCActionInterval)seq);
            label2.RunAction(repeat);

            m_time = 0;

            Schedule(step); //:@selector(step:)];
        }
コード例 #23
0
ファイル: Test2.cs プロジェクト: homocury/cocos2d-xna
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
            CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2);
            CCSprite sp3 = new CCSprite(TestResource.s_pPathSister1);
            CCSprite sp4 = new CCSprite(TestResource.s_pPathSister2);

            sp1.Position = (new CCPoint(100, s.Height / 2));
            sp2.Position = (new CCPoint(380, s.Height / 2));
            AddChild(sp1);
            AddChild(sp2);

            sp3.Scale = (0.25f);
            sp4.Scale = (0.25f);

            sp1.AddChild(sp3);
            sp2.AddChild(sp4);

            CCActionInterval a1 = new CCRotateBy (2, 360);
            CCActionInterval a2 = new CCScaleBy(2, 2);

            CCAction action1 = new CCRepeatForever ((CCActionInterval)CCSequence.FromActions(a1, a2, a2.Reverse())
                );
            CCAction action2 = new CCRepeatForever ((CCActionInterval)
                (CCSequence.FromActions(
                    (CCActionInterval) (a1.Copy()),
                    (CCActionInterval) (a2.Copy()),
                    a2.Reverse()))
                );

            sp2.AnchorPoint = (new CCPoint(0, 0));

            sp1.RunAction(action1);
            sp2.RunAction(action2);
        }
コード例 #24
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);
            }
        }
コード例 #25
0
ファイル: ConvertToNode.cs プロジェクト: eickegao/cocos2d-xna
        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);
            }
        }
コード例 #26
0
        public SceneTestLayer2()
        {
            m_timeCounter = 0;

            CCMenuItemFont item1 = CCMenuItemFont.Create("(2) replaceScene", onReplaceScene);
            CCMenuItemFont item2 = CCMenuItemFont.Create("(2) replaceScene w/transition", onReplaceSceneTran);
            CCMenuItemFont item3 = CCMenuItemFont.Create("(2) Go Back", onGoBack);
            _PopMenuItem = CCMenuItemFont.Create("(2) Test popScene w/transition", onPopSceneTran);

            _TheMenu = new CCMenu(item1, item2, item3, _PopMenuItem);
            _TheMenu.AlignItemsVertically();

            AddChild(_TheMenu);

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCSprite sprite = new CCSprite(s_pPathGrossini);
            AddChild(sprite);
            sprite.Position = new CCPoint(s.Width - 40, s.Height / 2);
            CCActionInterval rotate = new CCRotateBy (2, 360);
            CCAction repeat = new CCRepeatForever (rotate);
            sprite.RunAction(repeat);

            Schedule(testDealloc);
        }
コード例 #27
0
 public override CCFiniteTimeAction reverse()
 {
     return(CCRepeatForever.actionWithAction(m_pInnerAction.reverse() as CCActionInterval));
 }
コード例 #28
0
ファイル: ActionsTest.cs プロジェクト: KogleDK/cocos2d-xna-1
        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()));
        }
コード例 #29
0
        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);
        }
コード例 #30
0
ファイル: ActionsTest.cs プロジェクト: KogleDK/cocos2d-xna-1
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(2);

            var seq = CCSequence.FromActions(
                new CCRotateTo (0.5f, -20),
                new CCRotateTo (0.5f, 20));

            var rep1 = new CCRepeat (seq, 10);
            var rep2 = new CCRepeatForever ((CCActionInterval)(seq.Copy()));

            m_tamara.RunAction(rep1);
            m_kathia.RunAction(rep2);
        }
コード例 #31
0
ファイル: ActionsTest.cs プロジェクト: KogleDK/cocos2d-xna-1
        public void repeatForever(CCNode pSender)
        {
            var repeat = new CCRepeatForever (new CCRotateBy (1.0f, 360));

            pSender.RunAction(repeat);
        }
コード例 #32
0
 public override void OnNodeLoaded(CCNode node, CCNodeLoader nodeLoader)
 {
     CCRotateBy ccRotateBy = new CCRotateBy (20.0f, 360);
     CCRepeatForever ccRepeatForever = new CCRepeatForever (ccRotateBy);
     mBurstSprite.RunAction(ccRepeatForever);
 }
コード例 #33
0
ファイル: ActionsTest.cs プロジェクト: KogleDK/cocos2d-xna-1
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(1);
            var s = CCDirector.SharedDirector.WinSize;

            m_grossini.Position = new CCPoint(-200, s.Height / 2);
            var move = new CCMoveBy (2, new CCPoint(s.Width * 3, 0));
            var move_back = move.Reverse();
            var seq = CCSequence.FromActions(move, move_back);
            var rep = new CCRepeatForever (seq);

            m_grossini.RunAction(rep);

            RunAction(new CCFollow (m_grossini, new CCRect(0, 0, s.Width * 2 - 100, s.Height)));
        }
コード例 #34
0
ファイル: ActionsTest.cs プロジェクト: KogleDK/cocos2d-xna-1
        public override void OnEnter()
        {
            base.OnEnter();

            alignSpritesLeft(2);

            var a1 = new CCMoveBy (1, new CCPoint(150, 0));
            var action1 = new CCRepeat (
                CCSequence.FromActions(new CCPlace(new CCPoint(60, 60)), a1),
                3);
            var action2 = new CCRepeatForever (
                (CCSequence.FromActions((CCActionInterval) (a1.Copy()), a1.Reverse()))
                );

            m_kathia.RunAction(action1);
            m_tamara.RunAction(action2);
        }
コード例 #35
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);
        }
コード例 #36
0
ファイル: Texture2dTest.cs プロジェクト: eickegao/cocos2d-xna
        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.Texture.SetAntiAliasTexParameters();

            //
            // 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.Texture.SetAliasTexParameters();

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

            sprite2.RunAction(scaleforever);
            sprite.RunAction(scaleToo);
            CCTextureCache.SharedTextureCache.DumpCachedTextureInfo();
        }
コード例 #37
0
ファイル: ActionsTest.cs プロジェクト: KogleDK/cocos2d-xna-1
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(2);

            var act1 = new CCRotateTo (1, 90);
            var act2 = new CCRotateTo (1, 0);
            var seq = (CCSequence.FromActions(act1, act2));
            var rep1 = new CCRepeatForever ((CCActionInterval)seq);
            var rep2 = new CCRepeat ((CCFiniteTimeAction)(seq.Copy()), 10);

            m_tamara.RunAction(rep1);
            m_kathia.RunAction(rep2);
        }