Example #1
0
        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 = new CCTileMapAtlas(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.IsAntialiased = true;


            // 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 = new CCSequence(goUp, go, goDown, goBack);

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

            AddChild(voidNode, -1, kTagTileMap);
        }
Example #2
0
        public Parallax2()
        {
			var listener = new CCEventListenerTouchAllAtOnce();
			listener.OnTouchesMoved = onTouchesMoved;
			AddEventListener(listener);  

            // 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 = new CCTileMapAtlas(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.IsAntialiased = true;

            // 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, (int)KTag.kTagNode); // 0, (int)KTag.kTagNode);
        }
Example #3
0
        public override void OnEnter()
        {
            base.OnEnter(); CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            Background.Parent.RemoveChild(Background, true);
            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));

            Emitter = new CCParticleFlower(MidWindowPoint);

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

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

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

            CCFiniteTimeAction move = new CCMoveBy (4, new CCPoint(300, 0));
            CCFiniteTimeAction move_back = move.Reverse();
            CCFiniteTimeAction seq = new CCSequence(move, move_back);
            p.RunAction(new CCRepeatForever ((CCFiniteTimeAction) seq));
        }
Example #4
0
        void AddClouds()
        {
            float h = VisibleBoundsWorldspace.Size.Height;

            parallaxClouds = new CCParallaxNode {
                Position = new CCPoint (0, h)
            };

            AddChild (parallaxClouds);

            var cloud1 = new CCSprite ("cloud");
            var cloud2 = new CCSprite ("cloud");
            var cloud3 = new CCSprite ("cloud");

            float yRatio1 = 1.0f;
            float yRatio2 = 0.15f;
            float yRatio3 = 0.5f;

            parallaxClouds.AddChild (cloud1, 0, new CCPoint (1.0f, yRatio1), new CCPoint (100, -100 + h - (h * yRatio1)));
            parallaxClouds.AddChild (cloud2, 0, new CCPoint (1.0f, yRatio2), new CCPoint (250, -200 + h - (h * yRatio2)));
            parallaxClouds.AddChild (cloud3, 0, new CCPoint (1.0f, yRatio3), new CCPoint (400, -150 + h - (h * yRatio3)));
        }
 public CCSprite AddParallaxBackground(string idlayer, string fileName, int z, CCPoint ratio, CCPoint offset, CCParallaxNode container)
 {
     var dev = new CCSprite(fileName);
     container.AddChild(new CCSprite(fileName), 0, ratio, offset);
     return dev;
 }
        protected override void AddedToScene()
        {
            base.AddedToScene();

            //IA Initialization
            IASystem = new CSKSeuIA(this);

            //Map Tile
            // 1) Create the CCParallaxNode
            _backgroundNode = new CCParallaxNode();
            AddChild(_backgroundNode, -3);

            _foregroundNode = new CCParallaxNode();
            AddChild(_foregroundNode, 30);

            _bachMeteor = new CCSpriteBatchNode("meteors");
            AddChild(_bachMeteor);

            _bachShips = new CCSpriteBatchNode("ships");
            AddChild(_bachShips);
        }