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); }
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)); }