コード例 #1
0
ファイル: Parallax1.cs プロジェクト: HarkDev/cocos2d-xna
        public Parallax1()
        {
            // Top Layer, a simple image
            CCSprite cocosImage = new CCSprite(s_Power);
            // scale the image (optional)
            cocosImage.Scale = 2.5f;
            // change the transform anchor point to 0,0 (optional)
            cocosImage.AnchorPoint = new CCPoint(0, 0);

            // Middle layer: a Tile map atlas
            CCTileMapAtlas tilemap = CCTileMapAtlas.Create(s_TilesPng, s_LevelMapTga, 16, 16);
            tilemap.ReleaseMap();

            // change the transform anchor to 0,0 (optional)
            tilemap.AnchorPoint = new CCPoint(0, 0);

            // Anti Aliased images
            tilemap.Texture.SetAntiAliasTexParameters();

            // background layer: another image
            CCSprite background = new CCSprite(TestResource.s_back);
            // scale the image (optional)
            background.Scale = 1.5f;
            // change the transform anchor point (optional)
            background.AnchorPoint = new CCPoint(0, 0);

            // create a void node, a parent node
            CCParallaxNode voidNode = new CCParallaxNode();

            // NOW add the 3 layers to the 'void' node

            // background image is moved at a ratio of 0.4x, 0.5y
            voidNode.AddChild(background, -1, new CCPoint(0.4f, 0.5f), new CCPoint(0, 0));

            // tiles are moved at a ratio of 2.2x, 1.0y
            voidNode.AddChild(tilemap, 1, new CCPoint(2.2f, 1.0f), new CCPoint(0, -200));

            // top image is moved at a ratio of 3.0x, 2.5y
            voidNode.AddChild(cocosImage, 2, new CCPoint(3.0f, 2.5f), new CCPoint(200, 800));

            // now create some actions that will move the 'void' node
            // and the children of the 'void' node will move at different
            // speed, thus, simulation the 3D environment
            CCMoveBy goUp = new CCMoveBy (4, new CCPoint(0, -500));
            CCFiniteTimeAction goDown = goUp.Reverse();
            CCMoveBy go = new CCMoveBy (8, new CCPoint(-1000, 0));
            CCFiniteTimeAction goBack = go.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(goUp, go, goDown, goBack);

            voidNode.RunAction(new CCRepeatForever ((CCActionInterval) seq));

            AddChild(voidNode, -1, kTagTileMap);
        }
コード例 #2
0
ファイル: Parallax2.cs プロジェクト: HarkDev/cocos2d-xna
        public Parallax2()
        {
            TouchEnabled = true;

            // Top Layer, a simple image
            CCSprite cocosImage = new CCSprite(s_Power);
            // scale the image (optional)
            cocosImage.Scale = 2.5f;
            // change the transform anchor point to 0,0 (optional)
            cocosImage.AnchorPoint = new CCPoint(0, 0);

            // Middle layer: a Tile map atlas
            CCTileMapAtlas tilemap = CCTileMapAtlas.Create(s_TilesPng, s_LevelMapTga, 16, 16);
            tilemap.ReleaseMap();

            // change the transform anchor to 0,0 (optional)
            tilemap.AnchorPoint = new CCPoint(0, 0);

            // Anti Aliased images
            tilemap.Texture.SetAntiAliasTexParameters();

            // background layer: another image
            CCSprite background = new CCSprite(TestResource.s_back);
            // scale the image (optional)
            background.Scale = 1.5f;
            // change the transform anchor point (optional)
            background.AnchorPoint = new CCPoint(0, 0);

            // create a void node, a parent node
            CCParallaxNode voidNode = new CCParallaxNode();

            // NOW add the 3 layers to the 'void' node

            // background image is moved at a ratio of 0.4x, 0.5y
            voidNode.AddChild(background, -1, new CCPoint(0.4f, 0.5f), new CCPoint(0, 0));

            // tiles are moved at a ratio of 1.0, 1.0y
            voidNode.AddChild(tilemap, 1, new CCPoint(1.0f, 1.0f), new CCPoint(0, -200));

            // top image is moved at a ratio of 3.0x, 2.5y
            voidNode.AddChild(cocosImage, 2, new CCPoint(3.0f, 2.5f), new CCPoint(200, 1000));

            AddChild(voidNode, -1, kTagTileMap); // 0, (int)KTag.kTagNode);
        }
コード例 #3
0
ファイル: ParticleTest.cs プロジェクト: HarkDev/cocos2d-xna
        public override void OnEnter()
        {
            base.OnEnter();

            m_background.Parent.RemoveChild(m_background, true);
            m_background = null;

            CCParallaxNode p = new CCParallaxNode();
            AddChild(p, 5);

            CCSprite p1 = new CCSprite(TestResource.s_back3);
            CCSprite p2 = new CCSprite(TestResource.s_back3);

            p.AddChild(p1, 1, new CCPoint(0.5f, 1), new CCPoint(0, 250));
            p.AddChild(p2, 2, new CCPoint(1.5f, 1), new CCPoint(0, 50));

            m_emitter = new CCParticleFlower();

            m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire);

            p1.AddChild(m_emitter, 10);
            m_emitter.Position = new CCPoint(250, 200);

            CCParticleSun par = new CCParticleSun();
            p2.AddChild(par, 10);
            par.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire);

            CCActionInterval move = new CCMoveBy (4, new CCPoint(300, 0));
            CCFiniteTimeAction move_back = move.Reverse();
            CCFiniteTimeAction seq = CCSequence.FromActions(move, move_back);
            p.RunAction(new CCRepeatForever ((CCActionInterval) seq));
        }