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 = 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);
        }
Example #2
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));
        }
Example #3
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 #4
0
        public TileMapEditTest()
        {
            CCTileMapAtlas map = new CCTileMapAtlas(s_TilesPng, s_LevelMapTga, 16, 16);

            // Create an Aliased Atlas
            map.IsAntialiased = false;

            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
            // [tilemap releaseMap);
            // And if you are going to use, it you can access the data with:
            Schedule(updateMap, 0.2f);

            AddChild(map, 0, kTagTileMap);
            map.AnchorPoint = (new CCPoint(0, 0));
        }