コード例 #1
0
        public TextLayer() : base()
        {
            var backGround = new CCLayerColor(new CCColor4B(32, 128, 32, 255));

            AddChild(backGround, -20);

            BaseNode = new CCNode();
            var bg = new CCSprite(TestResource.s_back3);

            BaseNode.ContentSize = bg.ContentSize;
            BaseNode.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);

            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc      = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();

            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);

            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2      = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();

            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            AddChild(BaseNode);
        }
コード例 #2
0
        public void UpdateSpriteSize(int index, int edit)
        {
            ScheduleOnce((dt) => {
                if (index != -1 && edit != EditTypes.None)
                {
                    if (edit == EditTypes.UpdateSizeUp)
                    {
                        var mIconRef = iconList2[index];
                        var mSprite  = mIconRef.Sprite;

                        var action = new CCScaleBy(0.5f, 1.1f);

                        mSprite.AddAction(action);
                    }
                    else if (edit == EditTypes.UpdateSizeDown)
                    {
                        var mIconRef = iconList2[index];
                        var mSprite  = mIconRef.Sprite;

                        var action = new CCScaleBy(0.5f, 0.9f);

                        mSprite.AddAction(action);
                    }
                    else if (edit == EditTypes.UpdateSizeDefault)
                    {
                        var mIconRef = iconList2[index];
                        var mSprite  = mIconRef.Sprite;

                        var action = new CCScaleTo(0.5f, 1f);

                        mSprite.AddAction(action);
                    }
                }
            }, 0);
        }
コード例 #3
0
        public override void onEnter()
        {
            base.onEnter();

            float x, y;

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

            x = size.width;
            y = size.height;

            CCSprite bg = CCSprite.spriteWithFile("Images/background3");

            addChild(bg, 0, EffectAdvanceScene.kTagBackground);
            bg.position = new CCPoint(x / 2, y / 2);

            grossini = CCSprite.spriteWithFile("Images/grossinis_sister2");
            bg.addChild(grossini, 1, EffectAdvanceScene.kTagSprite1);
            grossini.position = new CCPoint(x / 3.0f, 200);
            CCActionInterval   sc      = CCScaleBy.actionWithDuration(2, 5);
            CCFiniteTimeAction sc_back = sc.reverse();

            grossini.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc, sc_back))));

            tamara = CCSprite.spriteWithFile("Images/grossinis_sister1");
            bg.addChild(tamara, 1, EffectAdvanceScene.kTagSprite2);
            tamara.position = new CCPoint(2 * x / 3.0f, 200);
            CCActionInterval   sc2      = CCScaleBy.actionWithDuration(2, 5);
            CCFiniteTimeAction sc2_back = sc2.reverse();

            tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc2, sc2_back))));

            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28);

            label.position = new CCPoint(x / 2, y - 80);
            addChild(label);
            label.tag = EffectAdvanceScene.kTagLabel;

            string strSubtitle = subtitle();

            if (strSubtitle != null)
            {
                CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16);
                addChild(l, 101);
                l.position = new CCPoint(size.width / 2, size.height - 80);
            }

            CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage("Images/b1", "Images/b2", this, backCallback);
            CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage("Images/r1", "Images/r2", this, restartCallback);
            CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage("Images/f1", "Images/f2", this, nextCallback);

            CCMenu menu = CCMenu.menuWithItems(item1, item2, item3);

            menu.position  = new CCPoint(0, 0);
            item1.position = new CCPoint(size.width / 2 - 100, 30);
            item2.position = new CCPoint(size.width / 2, 30);
            item3.position = new CCPoint(size.width / 2 + 100, 30);

            addChild(menu, 1);
        }
コード例 #4
0
        public TileMapTest()
        {
            CCTileMapAtlas map = new CCTileMapAtlas(s_TilesPng, s_LevelMapTga, 16, 16);

            // Convert it to "alias" (GL_LINEAR filtering)
            map.IsAntialiased = true;

            CCSize s = map.ContentSize;

            CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height);

            // If you are not going to use the Map, you can free it now
            // NEW since v0.7
            map.ReleaseMap();

            AddChild(map, 0, kTagTileMap);

            map.AnchorPoint = CCPoint.AnchorMiddleLeft;

            CCScaleBy          scale     = new CCScaleBy(4, 0.8f);
            CCFiniteTimeAction scaleBack = scale.Reverse();

            var seq = new CCSequence(scale, scaleBack);

            map.RunAction(new CCRepeatForever((CCFiniteTimeAction)seq));
        }
コード例 #5
0
        public TMXOrthoTest()
        {
            //
            // Test orthogonal with 3d camera and anti-alias textures
            //
            // it should not flicker. No artifacts should appear
            //
            //CCLayerColor* color = new CCLayerColor( ccc4(64,64,64,255) );
            //addChild(color, -1);

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test2");

            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

            CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height);

            var scale = new CCScaleBy(10, 0.1f);
            var back  = scale.Reverse();

            map.RepeatForever(scale, back);


            //float x, y, z;
            //map.Camera.GetEyeXyz(out x, out y, out z);
            //map.Camera.SetEyeXyz(x - 200, y, z + 300);
        }
コード例 #6
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);
        }
コード例 #7
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));
        }
コード例 #8
0
        private void performanceActions20(CCSprite pSprite)
        {
            Random random = new Random();
            CCSize size   = CCDirector.sharedDirector().getWinSize();

            if (random.Next() < 0.2f)
            {
                pSprite.position = new CCPoint((random.Next() % (int)size.width), (random.Next() % (int)size.height));
            }
            else
            {
                pSprite.position = new CCPoint(-1000, -1000);
            }

            float            period            = 0.5f + (random.Next() % 1000) / 500.0f;
            CCRotateBy       rot               = CCRotateBy.actionWithDuration(period, 360.0f * random.Next());
            CCActionInterval rot_back          = null;
            CCAction         permanentRotation = CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions(rot, rot_back));

            pSprite.runAction(permanentRotation);

            float            growDuration       = 0.5f + (random.Next() % 1000) / 500.0f;
            CCActionInterval grow               = CCScaleBy.actionWithDuration(growDuration, 0.5f, 0.5f);
            CCAction         permanentScaleLoop = CCRepeatForever.actionWithAction(CCSequence.actionOneTwo(grow, grow.reverse()));

            pSprite.runAction(permanentScaleLoop);
        }
コード例 #9
0
ファイル: TextLayer.cs プロジェクト: zhuruvl/CocosSharp
        public TextLayer() : base()
        {
            Color   = new CCColor3B(32, 128, 32);
            Opacity = 255;

            BaseNode = new CCNodeGrid();
            var effect = CurrentAction;

            BaseNode.RunAction(effect);
            AddChild(BaseNode, 0, EffectTestScene.kTagBackground);

            var bg = new CCSprite(TestResource.s_back3);

            BaseNode.AddChild(bg, 0);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);

            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc      = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();

            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);

            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2      = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();

            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));
        }
コード例 #10
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            // The .png image MUST be power of 2 in order to create a continue effect.
            // eg: 32x64, 512x128, 256x1024, 64x64, etc..
            var sprite = new CCSprite("Images/pattern1.png", new CCRect(0, 0, 4096, 4096));

            AddChild(sprite, -1, (int)enumTag.kTagSprite1);
            sprite.Position = new CCPoint(size.Width / 2, size.Height / 2);

            // Cocos2D-XNA no longer uses TexParameters.  Please use the XNA SamplerState
//            sprite.Texture.TexParameters = new CCTexParams() {  MagFilter = (uint)All.Linear,
//                                                                MinFilter = (uint)All.Linear,
//                                                                WrapS = (uint)All.Repeat,
//                                                                WrapT = (uint)All.Repeat
//                                                              };

            sprite.Texture.SamplerState = SamplerState.LinearWrap;

            var rotate = new CCRotateBy(4, 360);

            sprite.RunAction(rotate);
            var scale     = new CCScaleBy(2, 0.04f);
            var scaleBack = (CCScaleBy)scale.Reverse();
            var seq       = new CCSequence(scale, scaleBack);

            sprite.RunAction(seq);
        }
コード例 #11
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize size = CCDirector.SharedDirector.WinSize;

            // The .png image MUST be power of 2 in order to create a continue effect.
            // eg: 32x64, 512x128, 256x1024, 64x64, etc..
            var sprite = new CCSprite("Images/pattern1.png", new CCRect(0, 0, 4096, 4096));

            AddChild(sprite, -1, (int)enumTag.kTagSprite1);
            sprite.Position = new CCPoint(size.Width / 2, size.Height / 2);

#if OPENGL
            sprite.Texture.TexParameters = new CCTexParams()
            {
                MagFilter = (uint)All.Linear,
                MinFilter = (uint)All.Linear,
                WrapS     = (uint)All.Repeat,
                WrapT     = (uint)All.Repeat
            };
#else
            sprite.Texture.SamplerState = SamplerState.LinearWrap;
#endif
            var rotate = new CCRotateBy(4, 360);
            sprite.RunAction(rotate);
            var scale     = new CCScaleBy(2, 0.04f);
            var scaleBack = (CCScaleBy)scale.Reverse();
            var seq       = new CCSequence(scale, scaleBack);
            sprite.RunAction(seq);
        }
コード例 #12
0
        private void performanceActions20(CCSprite pSprite)
        {
            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            if (CCRandom.Float_0_1() < 0.2f)
            {
                pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height));
            }
            else
            {
                pSprite.Position = new CCPoint(-1000, -1000);
            }

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

            pSprite.RunAction(permanentRotation);

            float growDuration      = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
            CCFiniteTimeAction grow = new CCScaleBy(growDuration, 0.5f, 0.5f);
            CCAction           permanentScaleLoop = new CCRepeatForever(new CCSequence(grow, grow.Reverse()));

            pSprite.RunAction(permanentScaleLoop);
        }
コード例 #13
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);
        }
コード例 #14
0
ファイル: Test2.cs プロジェクト: ztaksoftware/CocosSharp
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            var sp1 = new CCSprite(TestResource.s_pPathSister1);
            var sp2 = new CCSprite(TestResource.s_pPathSister2);
            var sp3 = new CCSprite(TestResource.s_pPathSister1);
            var 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);

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

            var action1 = new CCRepeatForever(a1, a2, a2.Reverse());

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

            sp1.RunAction(action1);
            sp2.RunAction(action1);
        }
コード例 #15
0
        public TextLayer() : base()
        {
            contentLayer = new CCLayer();
            CCCamera contentCamera = new CCCamera(Camera.OrthographicViewSizeWorldspace, Camera.CenterInWorldspace, Camera.TargetInWorldspace);

            contentLayer.Camera = contentCamera;

            var bg = new CCSprite(TestResource.s_back3);

            BaseNode = bg;
            contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground);

            var Kathia = new CCSprite(TestResource.s_pPathSister2);

            BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia);

            var sc      = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();

            Kathia.RunAction(new CCRepeatForever(sc, sc_back));


            var Tamara = new CCSprite(TestResource.s_pPathSister1);

            BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara);

            var sc2      = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();

            Tamara.RunAction(new CCRepeatForever(sc2, sc2_back));

            var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255));

            contentLayer.AddChild(colorBackground, -1);
        }
コード例 #16
0
        private void performanceActions20(CCSprite pSprite)
        {
            CCSize size = CCDirector.SharedDirector.WinSize;

            if (Random.Float_0_1() < 0.2f)
            {
                pSprite.Position = new CCPoint((Random.Next() % (int)size.Width), (Random.Next() % (int)size.Height));
            }
            else
            {
                pSprite.Position = new CCPoint(-1000, -1000);
            }

            float      period            = 0.5f + (Random.Next() % 1000) / 500.0f;
            CCRotateBy rot               = new CCRotateBy(period, 360.0f * Random.Float_0_1());
            var        rot_back          = (CCActionInterval)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);
        }
コード例 #17
0
        public override void OnEnter()
        {
            base.OnEnter();

            float x, y;

            CCSize size = CCDirector.SharedDirector.WinSize;

            x = size.Width;
            y = size.Height;

            CCSprite bg = new CCSprite("Images/background3");

            AddChild(bg, 0, EffectAdvanceScene.kTagBackground);
            bg.Position = new CCPoint(x / 2, y / 2);

            grossini = new CCSprite("Images/grossinis_sister2");
            bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1);
            grossini.Position = new CCPoint(x / 3.0f, 200);
            CCActionInterval   sc      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc_back = sc.Reverse();

            grossini.RunAction(new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(sc, sc_back))));

            tamara = new CCSprite("Images/grossinis_sister1");
            bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2);
            tamara.Position = new CCPoint(2 * x / 3.0f, 200);
            CCActionInterval   sc2      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc2_back = sc2.Reverse();

            tamara.RunAction(new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back))));

            CCLabelTTF label = new CCLabelTTF(title(), "arial", 28);

            label.Position = new CCPoint(x / 2, y - 80);
            AddChild(label);
            label.Tag = EffectAdvanceScene.kTagLabel;

            string strSubtitle = subtitle();

            if (strSubtitle != null)
            {
                CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16);
                AddChild(l, 101);
                l.Position = new CCPoint(size.Width / 2, size.Height - 80);
            }

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

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

            menu.Position  = new CCPoint(0, 0);
            item1.Position = new CCPoint(size.Width / 2 - 100, 30);
            item2.Position = new CCPoint(size.Width / 2, 30);
            item3.Position = new CCPoint(size.Width / 2 + 100, 30);

            AddChild(menu, 1);
        }
コード例 #18
0
        public TextLayer()
        {
            InitWithColor(CCTypes.CreateColor(32, 32, 32, 255));

            var node = new CCNode();
            CCActionInterval effect = getAction();

            node.RunAction(effect);
            AddChild(node, 0, EffectTestScene.kTagBackground);

            var bg = new CCSprite(TestResource.s_back3);

            node.AddChild(bg, 0);
            bg.AnchorPoint = new CCPoint(0.5f, 0.5f);
            bg.Position    = CCVisibleRect.Center;

            var grossini = new CCSprite(TestResource.s_pPathSister2);

            node.AddChild(grossini, 1);
            grossini.Position = new CCPoint(CCVisibleRect.Left.X + CCVisibleRect.VisibleRect.Size.Width / 3,
                                            CCVisibleRect.Center.Y);
            CCActionInterval   sc      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc_back = sc.Reverse();

            grossini.RunAction(new CCRepeatForever((new CCSequence(sc, sc_back))));

            var tamara = new CCSprite(TestResource.s_pPathSister1);

            node.AddChild(tamara, 1);
            tamara.Position = new CCPoint(CCVisibleRect.Left.X + 2 * CCVisibleRect.VisibleRect.Size.Width / 3,
                                          CCVisibleRect.Center.Y);
            CCActionInterval   sc2      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc2_back = sc2.Reverse();

            tamara.RunAction(new CCRepeatForever((new CCSequence(sc2, sc2_back))));

            var label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32);

            label.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Top.Y - 80);
            AddChild(label);
            label.Tag = EffectTestScene.kTagLabel;

            var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback);
            var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback);
            var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback);

            var menu = new CCMenu(item1, item2, item3);

            menu.Position  = CCPoint.Zero;
            item1.Position = new CCPoint(CCVisibleRect.Center.X - item2.ContentSize.Width * 2,
                                         CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);
            item2.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);
            item3.Position = new CCPoint(CCVisibleRect.Center.X + item2.ContentSize.Width * 2,
                                         CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);

            AddChild(menu, 1);

            Schedule(checkAnim);
        }
コード例 #19
0
ファイル: CCScaleBy.cs プロジェクト: liwq-net/liwq718
        /// <summary>
        ///  creates the action with and X factor and a Y factor
        /// </summary>
        /// <param name="duration"></param>
        /// <param name="sx"></param>
        /// <param name="sy"></param>
        /// <returns></returns>
        public static new CCScaleBy actionWithDuration(float duration, float sx, float sy)
        {
            CCScaleBy pScaleBy = new CCScaleBy();
            pScaleBy.initWithDuration(duration, sx, sy);
            //pScaleBy->autorelease();

            return pScaleBy;
        }
コード例 #20
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test2");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

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


            CCTMXLayer layer = map.layerNamed("Layer 0");

            layer.Texture.setAntiAliasTexParameters();

            map.scale = 1;

            CCSprite tile0 = layer.tileAt(new CCPoint(1, 63));
            CCSprite tile1 = layer.tileAt(new CCPoint(2, 63));
            CCSprite tile2 = layer.tileAt(new CCPoint(3, 62));//ccp(1,62));
            CCSprite tile3 = layer.tileAt(new CCPoint(2, 62));

            tile0.anchorPoint = new CCPoint(0.5f, 0.5f);
            tile1.anchorPoint = new CCPoint(0.5f, 0.5f);
            tile2.anchorPoint = new CCPoint(0.5f, 0.5f);
            tile3.anchorPoint = new CCPoint(0.5f, 0.5f);

            CCActionInterval   move      = CCMoveBy.actionWithDuration(0.5f, new CCPoint(0, 160));
            CCActionInterval   rotate    = CCRotateBy.actionWithDuration(2, 360);
            CCActionInterval   scale     = CCScaleBy.actionWithDuration(2, 5);
            CCActionInterval   opacity   = CCFadeOut.actionWithDuration(2);
            CCActionInterval   fadein    = CCFadeIn.actionWithDuration(2);
            CCActionInterval   scaleback = CCScaleTo.actionWithDuration(1, 1);
            CCActionInstant    finish    = CCCallFuncN.actionWithTarget(this, removeSprite);
            CCFiniteTimeAction seq0      = CCSequence.actions(move, rotate, scale, opacity, fadein, scaleback, finish);
            CCActionInterval   seq1      = (CCActionInterval)(seq0.copy());
            CCActionInterval   seq2      = (CCActionInterval)(seq0.copy());
            CCActionInterval   seq3      = (CCActionInterval)(seq0.copy());

            tile0.runAction(seq0);
            tile1.runAction(seq1);
            tile2.runAction(seq2);
            tile3.runAction(seq3);


            m_gid = layer.tileGIDAt(new CCPoint(0, 63));
            ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid);

            schedule(updateCol, 2.0f);
            schedule(repaintWithGID, 2.0f);
            schedule(removeTiles, 1.0f);

            ////----UXLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads());
            ////----UXLOG("++++children: %d", layer->getChildren()->count() );

            m_gid2 = 0;
        }
コード例 #21
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);
            }
        }
コード例 #22
0
ファイル: CCScaleBy.cs プロジェクト: liwq-net/liwq718
        /// <summary>
        ///  creates the action with and X factor and a Y factor
        /// </summary>
        /// <param name="duration"></param>
        /// <param name="sx"></param>
        /// <param name="sy"></param>
        /// <returns></returns>
        public new static CCScaleBy actionWithDuration(float duration, float sx, float sy)
        {
            CCScaleBy pScaleBy = new CCScaleBy();

            pScaleBy.initWithDuration(duration, sx, sy);
            //pScaleBy->autorelease();

            return(pScaleBy);
        }
コード例 #23
0
        public TMXOrthoTest() : base("TileMaps/orthogonal-test2")
        {
            // it should not flicker. No artifacts should appear

            var scale = new CCScaleBy(10, 0.1f);
            var back  = scale.Reverse();

            tileLayersContainer.RepeatForever(scale, back);
        }
コード例 #24
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);
        }
コード例 #25
0
ファイル: Atlas4.cs プロジェクト: chengcong/cocos2d-xna
        public Atlas4()
        {
            m_time = 0;

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

            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(0);
            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);
            CCFiniteTimeAction scale_back  = scale.reverse();
            CCFiniteTimeAction scale_seq   = CCSequence.actions(scale, scale_back);
            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);
            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/fnt/bitmapFontTest");

            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);
        }
コード例 #26
0
        protected override void AddedToScene()
        {
            base.AddedToScene();
            bubbleMax  = CCRandom.Next(4, 6);
            growthTime = CCRandom.Next(3, 5);
            scale      = new CCScaleBy(growthTime, bubbleMax);
            this.AddAction(scale);

            move1          = new CCMoveBy(.2f, new CCPoint(4, 4));
            move2          = new CCMoveBy(.24f, new CCPoint(-4, -4));
            repeatedAction = new CCRepeatForever(move1, move2);
        }
コード例 #27
0
        protected override void AddedToScene()
        {
            base.AddedToScene();
            _bubbleMax  = CCRandom.Next(4, 6);
            _growthTime = CCRandom.Next(3, _maxGrowthTime);
            _scale      = new CCScaleBy(_growthTime, _bubbleMax);
            AddAction(_scale);

            _move1          = new CCMoveBy(.2f, new CCPoint(4, 4));
            _move2          = new CCMoveBy(.24f, new CCPoint(-4, -4));
            _repeatedAction = new CCRepeatForever(_move1, _move2);
        }
コード例 #28
0
        public SpriteAliased()
        {
            sprite1 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121));
            AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1);

            sprite2 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121));
            AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2);

            var scale      = new CCScaleBy(2, 5);
            var scale_back = scale.Reverse();

            seq = new CCSequence(scale, scale_back);
        }
コード例 #29
0
        public override void OnEnter()
        {
            CCRect visibleBounds = Layer.VisibleBoundsWorldspace;

            base.OnEnter();

            bgNode             = new CCNodeGrid();
            bgNode.AnchorPoint = CCPoint.AnchorMiddle;
            contentLayer.AddChild(bgNode);
            //bgNode.Position = visibleBounds.Center;

            var bg = new CCSprite("Images/background3");

            //bg.AnchorPoint = CCPoint.AnchorMiddle;
            bg.Position = visibleBounds.Center;

            //bgNode.ContentSize = bg.ContentSize;

            bgNode.AddChild(bg);


            Target1             = new CCNodeGrid();
            Target1.AnchorPoint = CCPoint.AnchorMiddle;

            grossini = new CCSprite("Images/grossinis_sister2");
            Target1.AddChild(grossini);
            bgNode.AddChild(Target1);

            Target1.Position = bg.BoundingBox.Center + new CCPoint(-100.0f, 0.0f);
            //grossini.Position =

            var sc      = new CCScaleBy(2, 5);
            var sc_back = sc.Reverse();

            Target1.RepeatForever(sc, sc_back);

            Target2             = new CCNodeGrid();
            Target2.AnchorPoint = CCPoint.AnchorMiddle;

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

            Target2.AddChild(tamara);
            bgNode.AddChild(Target2);

            Target2.Position = bg.BoundingBox.Center + new CCPoint(100.0f, 0.0f);

            var sc2      = new CCScaleBy(2, 5);
            var sc2_back = sc2.Reverse();

            tamara.RepeatForever(sc2, sc2_back);
        }
コード例 #30
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test2");

            AddChild(map, 0, kTagTileMap);

            CCTMXLayer layer = map.LayerNamed("Layer 0");

            layer.IsAntialiased = true;

            map.Scale = (1);

            CCSprite tile0 = layer.TileAt(new CCPoint(1, 63));
            CCSprite tile1 = layer.TileAt(new CCPoint(2, 63));
            CCSprite tile2 = layer.TileAt(new CCPoint(3, 62)); //new CCPoint(1,62));
            CCSprite tile3 = layer.TileAt(new CCPoint(2, 62));

            tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f));

            CCMoveBy    move      = new CCMoveBy(0.5f, new CCPoint(0, 160));
            CCRotateBy  rotate    = new CCRotateBy(2, 360);
            CCScaleBy   scale     = new CCScaleBy(2, 5);
            CCFadeOut   opacity   = new CCFadeOut(2);
            CCFadeIn    fadein    = new CCFadeIn(2);
            CCScaleTo   scaleback = new CCScaleTo(1, 1);
            CCCallFuncN finish    = new CCCallFuncN(removeSprite);
            CCSequence  sequence  = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);

            tile0.RunAction(sequence);
            tile1.RunAction(sequence);
            tile2.RunAction(sequence);
            tile3.RunAction(sequence);


            m_gid = layer.TileGIDAt(new CCPoint(0, 63));
            ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid);

            Schedule(updateCol, 2.0f);
            Schedule(repaintWithGID, 2.0f);
            Schedule(removeTiles, 1.0f);

            ////----UXLOG("++++atlas quantity: %d", layer.textureAtlas().getTotalQuads());
            ////----UXLOG("++++children: %d", layer.getChildren().count() );

            m_gid2 = 0;
        }
コード例 #31
0
        void LoadStartLabels()
        {
            var bounds = mainLayer.VisibleBoundsWorldspace;
            var center = bounds.Center;

            var scaleAction = new CCScaleBy(0.5f, 1.0f, 1.5f);
            var fadeAction  = new CCFadeIn(0.5f);

            scaleLabelAction = new CCSequence(new CCSpawn(scaleAction, fadeAction),
                                              new CCEaseElasticInOut(scaleAction.Reverse(), 1.0f));

            tintLabelAction = new CCSequence(new CCTintTo(1.0f, 100, 152, 219),
                                             new CCTintTo(1.0f, 255, 255, 255));
        }
コード例 #32
0
ファイル: CCScaleBy.cs プロジェクト: liwq-net/liwq718
        public override CCObject copyWithZone(CCZone pZone)
        {
            CCZone pNewZone = null;
            CCScaleTo pCopy = null;

            if (pZone != null && pZone.m_pCopyObject != null)
            {
                //in case of being called at sub class
                pCopy = (CCScaleBy)(pZone.m_pCopyObject);
            }
            else
            {
                pCopy = new CCScaleBy();
                pZone = pNewZone = new CCZone(pCopy);
            }

            base.copyWithZone(pZone);

            pCopy.initWithDuration(Duration, m_fEndScaleX, m_fEndScaleY);

            //CC_SAFE_DELETE(pNewZone);
            return pCopy;
        }
コード例 #33
0
ファイル: CCScaleBy.cs プロジェクト: pekayatt/cocos2d-xna
 protected CCScaleBy(CCScaleBy copy)
     : base(copy)
 {
     // Handled by the base class.
 }
コード例 #34
0
ファイル: EffectsTest.cs プロジェクト: trustme/cocos2d-mono
        public TextLayer()
            : base()
        {
            SizeF s = CCDirector.SharedDirector ().WinSize ();
            float x = s.Width;
            float y = s.Height;

            CCNode node = new CCNode ();
            CCAction effectClass = RestartAction (3f);
            node.RunAction (effectClass);
            this.AddChild (node, 0, (int)EffectLayers.kTagBackground);

            CCSprite bg = new CCSprite ("background3.png", true);
            node.AddChild (bg, 0);
            bg.Position = new PointF(x/2, y/2);

            CCSprite grossini = new CCSprite ("grossinis_sister2.png", true);
            node.AddChild (grossini, 1);
            grossini.Position = new PointF(x/3, y/2);
            CCScaleBy sc = new CCScaleBy (2, 5);
            CCActionInterval sc_back = sc.Reverse ();
            grossini.RunAction (new CCRepeatForever (new CCSequence (sc, sc_back)));

            CCSprite tamara = new CCSprite ("grossinis_sister1.png", true);
            node.AddChild (tamara, 1, (int)EffectLayers.kTagSprite2);
            tamara.Position = new PointF (2*x/3, y/2);
            CCScaleBy sc2 = new CCScaleBy (2, 5);
            CCActionInterval sc2_back = sc2.Reverse ();
            tamara.RunAction (new CCRepeatForever (new CCSequence (sc2, sc2_back)));

            CCLabelTTF label = new CCLabelTTF (effectsList[actionIdx].Replace("Demo", ""), "Marker Felt", 32);
            label.Position = new PointF (x/2, y-80);
            this.AddChild (label);
            label.Tag = (int)EffectLayers.kTagLabel;

            //menu
            CCMenuItemImage item1 = new CCMenuItemImage ("b1.png", "b2.png", null, BackCallback);
            CCMenuItemImage item2 = new CCMenuItemImage ("r1.png", "r2.png", null, RestartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage ("f1.png", "f2.png", null, NextCallback);

            CCMenu menu = new CCMenu (item1, item2, item3);
            menu.Position = PointF.Empty;
            item1.Position = new PointF(s.Width/2 - item2.ContentSize.Width*2, item2.ContentSize.Height/2);
            item2.Position = new PointF( s.Width/2, item2.ContentSize.Height/2);
            item3.Position = new PointF( s.Width/2 + item2.ContentSize.Width*2, item2.ContentSize.Height/2);
            this.AddChild (menu, 1);

            this.Schedule (new MonoMac.ObjCRuntime.Selector ("checkAnim:"));
        }