public NodeToWorld() { // // This code tests that nodeToParent works OK: // - It tests different anchor Points // - It tests different children anchor points CCSprite back = new CCSprite(TestResource.s_back3); AddChild(back, -10); back.AnchorPoint = (new CCPoint(0, 0)); CCSize backSize = back.ContentSize; CCMenuItem item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect); CCMenu menu = new CCMenu(item); menu.AlignItemsVertically(); menu.Position = (new CCPoint(backSize.Width / 2, backSize.Height / 2)); back.AddChild(menu); CCActionInterval rot = new CCRotateBy (5, 360); CCAction fe = new CCRepeatForever (rot); item.RunAction(fe); CCActionInterval move = new CCMoveBy (3, new CCPoint(200, 0)); var move_back = (CCActionInterval) move.Reverse(); CCFiniteTimeAction seq = CCSequence.FromActions(move, move_back); CCAction fe2 = new CCRepeatForever ((CCActionInterval) seq); back.RunAction(fe2); }
public SpriteBatchNodeChildren() { CCSize s = CCDirector.SharedDirector.WinSize; // parents CCSpriteBatchNode batch = CCSpriteBatchNode.Create("animations/grossini", 50); AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist"); CCSprite sprite1 = new CCSprite("grossini_dance_01.png"); sprite1.Position = (new CCPoint(s.Width / 3, s.Height / 2)); CCSprite sprite2 = new CCSprite("grossini_dance_02.png"); sprite2.Position = (new CCPoint(50, 50)); CCSprite sprite3 = new CCSprite("grossini_dance_03.png"); sprite3.Position = (new CCPoint(-50, -50)); batch.AddChild(sprite1); sprite1.AddChild(sprite2); sprite1.AddChild(sprite3); // BEGIN NEW CODE var animFrames = new List<CCSpriteFrame>(); string str = ""; for (int i = 1; i < 15; i++) { string temp = ""; if (i<10) { temp = "0" + i; } else { temp = i.ToString(); } str = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str); animFrames.Add(frame); } CCAnimation animation = CCAnimation.Create(animFrames, 0.2f); sprite1.RunAction(new CCRepeatForever (new CCAnimate (animation))); // END NEW CODE CCActionInterval action = new CCMoveBy (2, new CCPoint(200, 0)); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCActionInterval action_rot = new CCRotateBy (2, 360); CCActionInterval action_s = new CCScaleBy(2, 2); CCActionInterval action_s_back = (CCActionInterval)action_s.Reverse(); CCActionInterval seq2 = (CCActionInterval)action_rot.Reverse(); sprite2.RunAction(new CCRepeatForever (seq2)); sprite1.RunAction((CCAction)(new CCRepeatForever (action_rot))); sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(action, action_back))))); sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(action_s, action_s_back))))); }
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); }
public override void OnEnter() { base.OnEnter(); CCNode bg = GetChildByTag(EffectAdvanceScene.kTagBackground); CCNode target1 = bg.GetChildByTag(EffectAdvanceScene.kTagSprite1); CCNode target2 = bg.GetChildByTag(EffectAdvanceScene.kTagSprite2); CCActionInterval waves = CCWaves.Create(5, 20, true, false, new CCGridSize(15, 10), 5); CCActionInterval shaky = CCShaky3D.Create(4, false, new CCGridSize(15, 10), 5); target1.RunAction(new CCRepeatForever (waves)); target2.RunAction(new CCRepeatForever (shaky)); // moving background. Testing issue #244 CCActionInterval move = new CCMoveBy (3, new CCPoint(200, 0)); bg.RunAction(new CCRepeatForever (CCSequence.FromActions(move, move.Reverse()))); }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; // the root object just rotates around m_root = new CCSprite(s_pPathR1); AddChild(m_root, 1); m_root.Position = new CCPoint(s.Width / 2, s.Height / 2); // the target object is offset from root, and the streak is moved to follow it m_target = new CCSprite(s_pPathR1); m_root.AddChild(m_target); m_target.Position = new CCPoint(s.Width / 4, 0); // create the streak object and add it to the scene streak = CCMotionStreak.Create(2, 3, 32, CCTypes.CCGreen, s_streak); streak.FastMode = true; AddChild(streak); // schedule an update on each frame so we can syncronize the streak with the target Schedule(onUpdate); var a1 = new CCRotateBy (2, 360); var action1 = new CCRepeatForever (a1); var motion = new CCMoveBy (2, new CCPoint(100, 0)); m_root.RunAction(new CCRepeatForever ((CCActionInterval)CCSequence.FromActions(motion, motion.Reverse()))); m_root.RunAction(action1); var colorAction = new CCRepeatForever ((CCActionInterval) CCSequence.FromActions( new CCTintTo (0.2f, 255, 0, 0), new CCTintTo (0.2f, 0, 255, 0), new CCTintTo (0.2f, 0, 0, 255), new CCTintTo (0.2f, 0, 255, 255), new CCTintTo (0.2f, 255, 255, 0), new CCTintTo (0.2f, 255, 0, 255), new CCTintTo (0.2f, 255, 255, 255) ) ); streak.RunAction(colorAction); }
public ParticleDemo() { InitWithColor(CCTypes.CreateColor(127, 127, 127, 255)); m_emitter = null; TouchEnabled = true; CCSize s = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF(title(), "arial", 28); AddChild(label, 100, 1000); label.Position = new CCPoint(s.Width / 2, s.Height - 50); CCLabelTTF tapScreen = new CCLabelTTF(subtitle(), "arial", 20); tapScreen.Position = new CCPoint(s.Width / 2, s.Height - 80); AddChild(tapScreen, 100); CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); CCMenuItemToggle item4 = CCMenuItemToggle.Create(toggleCallback, CCMenuItemFont.Create("Free Movement"), CCMenuItemFont.Create("Relative Movement"), CCMenuItemFont.Create("Grouped Movement")); CCMenu menu = new CCMenu(item1, item2, item3, item4); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(s.Width / 2 - 100, 30); item2.Position = new CCPoint(s.Width / 2, 30); item3.Position = new CCPoint(s.Width / 2 + 100, 30); item4.Position = new CCPoint(0, 100); item4.AnchorPoint = new CCPoint(0, 0); AddChild(menu, 100); CCLabelAtlas labelAtlas; try { labelAtlas = CCLabelAtlas.Create("0000", "Images/fps_Images", 16, 24, '.'); } catch (Exception) { labelAtlas = CCLabelAtlas.Create("0000", "Images/fps_Images", 16, 24, '.'); } AddChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas); labelAtlas.Position = new CCPoint(s.Width - 66, 50); // moving background m_background = new CCSprite(TestResource.s_back3); AddChild(m_background, 5); m_background.Position = new CCPoint(s.Width / 2, s.Height - 180); CCActionInterval move = new CCMoveBy (4, new CCPoint(300, 0)); CCFiniteTimeAction move_back = move.Reverse(); CCFiniteTimeAction seq = CCSequence.FromActions(move, move_back); m_background.RunAction(new CCRepeatForever ((CCActionInterval) seq)); Schedule(step); }
public override void OnEnter() { base.OnEnter(); var s = CCDirector.SharedDirector.WinSize; var move = new CCMoveBy (3, new CCPoint(s.Width - 130, 0)); var move_back = move.Reverse(); var move_ease_in = new CCEaseExponentialIn((CCActionInterval) (move.Copy())); var move_ease_in_back = move_ease_in.Reverse(); var move_ease_out = new CCEaseExponentialOut((CCActionInterval) (move.Copy())); var move_ease_out_back = move_ease_out.Reverse(); var delay = new CCDelayTime (0.25f); var seq1 = CCSequence.FromActions(move, delay, move_back, (CCFiniteTimeAction) delay.Copy()); var seq2 = CCSequence.FromActions(move_ease_in, (CCFiniteTimeAction) delay.Copy(), move_ease_in_back, (CCFiniteTimeAction) delay.Copy()); var seq3 = CCSequence.FromActions(move_ease_out, (CCFiniteTimeAction) delay.Copy(), move_ease_out_back, (CCFiniteTimeAction) delay.Copy()); m_grossini.RunAction(new CCRepeatForever (seq1)); m_tamara.RunAction(new CCRepeatForever (seq2)); m_kathia.RunAction(new CCRepeatForever (seq3)); }
public override void OnEnter() { base.OnEnter(); var s = CCDirector.SharedDirector.WinSize; var move = new CCMoveBy (3, new CCPoint(s.Width - 130, 0)); var move_back = move.Reverse(); var move_ease = new CCEaseSineInOut((CCActionInterval) (move.Copy())); var move_ease_back = move_ease.Reverse(); var delay = new CCDelayTime (0.25f); var seq1 = CCSequence.FromActions(move, delay, move_back, (CCFiniteTimeAction) delay.Copy()); var seq2 = CCSequence.FromActions(move_ease, (CCFiniteTimeAction) delay.Copy(), move_ease_back, (CCFiniteTimeAction) delay.Copy()); positionForTwo(); m_grossini.RunAction(new CCRepeatForever (seq1)); m_tamara.RunAction(new CCRepeatForever (seq2)); }
public TMXOrthoZorder() { CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test-zorder"); AddChild(map, 0, kTagTileMap); CCSize s = map.ContentSize; m_tamara = new CCSprite(s_pPathSister1); map.AddChild(m_tamara, map.Children.Count); m_tamara.AnchorPoint = (new CCPoint(0.5f, 0)); CCMoveBy move = new CCMoveBy (10, new CCPoint(400, 450)); CCFiniteTimeAction back = move.Reverse(); CCSequence seq = CCSequence.FromActions(move, back); m_tamara.RunAction(new CCRepeatForever (seq)); Schedule(repositionSprite); }
public override void OnEnter() { base.OnEnter(); var size = CCDirector.SharedDirector.WinSize; var move = new CCMoveBy (3, new CCPoint(size.Width - 130, 0)); var move_back = (CCActionInterval) move.Reverse(); var move_ease_in = new CCEaseIn((CCActionInterval) move.Copy(), 2.5f); var move_ease_in_back = move_ease_in.Reverse(); var move_ease_out = new CCEaseOut((CCActionInterval) move.Copy(), 2.5f); var move_ease_out_back = move_ease_out.Reverse(); var delay = new CCDelayTime (0.25f); var seq1 = CCSequence.FromActions(move, delay, move_back, (CCFiniteTimeAction) delay.Copy()); var seq2 = CCSequence.FromActions(move_ease_in, (CCFiniteTimeAction) delay.Copy(), move_ease_in_back, (CCFiniteTimeAction) delay.Copy()); var seq3 = CCSequence.FromActions(move_ease_out, (CCFiniteTimeAction) delay.Copy(), move_ease_out_back, (CCFiniteTimeAction) delay.Copy()); var a2 = m_grossini.RunAction(new CCRepeatForever ((CCActionInterval)seq1)); a2.Tag = 1; var a1 = m_tamara.RunAction(new CCRepeatForever ((CCActionInterval)seq2)); a1.Tag = 1; var a = m_kathia.RunAction(new CCRepeatForever ((CCActionInterval)seq3)); a.Tag = 1; Schedule(testStopAction, 6.25f); }
public TMXIsoZorder() { CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/iso-test-zorder"); AddChild(map, 0, kTagTileMap); CCSize s = map.ContentSize; CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height); map.Position = new CCPoint(-s.Width / 2, 0); m_tamara = new CCSprite(s_pPathSister1); map.AddChild(m_tamara, map.Children.Count); float mapWidth = map.MapSize.Width * map.TileSize.Width; m_tamara.Position = CCMacros.CCPointPixelsToPoints(new CCPoint(mapWidth / 2, 0)); m_tamara.AnchorPoint = (new CCPoint(0.5f, 0)); CCMoveBy move = new CCMoveBy (10, new CCPoint(300, 250)); CCFiniteTimeAction back = move.Reverse(); CCSequence seq = CCSequence.FromActions(move, back); m_tamara.RunAction(new CCRepeatForever (seq)); Schedule(repositionSprite); }
public TMXOrthoVertexZ() { CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test-vertexz"); AddChild(map, 0, kTagTileMap); CCSize s = map.ContentSize; // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you // can use any CCSprite and it will work OK. CCTMXLayer layer = map.LayerNamed("trees"); m_tamara = layer.TileAt(new CCPoint(0, 11)); CCLog.Log("tamara vertexZ: {0}", m_tamara.VertexZ); CCMoveBy move = new CCMoveBy (10, new CCPoint(400, 450) * (1f / CCMacros.CCContentScaleFactor())); CCFiniteTimeAction back = move.Reverse(); CCSequence seq = CCSequence.FromActions(move, back); m_tamara.RunAction(new CCRepeatForever (seq)); Schedule(repositionSprite); }
public override void OnEnter() { base.OnEnter(); centerSprites(1); var s = CCDirector.SharedDirector.WinSize; m_grossini.Position = new CCPoint(-200, s.Height / 2); var move = new CCMoveBy (2, new CCPoint(s.Width * 3, 0)); var move_back = move.Reverse(); var seq = CCSequence.FromActions(move, move_back); var rep = new CCRepeatForever (seq); m_grossini.RunAction(rep); RunAction(new CCFollow (m_grossini, new CCRect(0, 0, s.Width * 2 - 100, s.Height))); }
public TMXIsoVertexZ() { CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/iso-test-vertexz"); AddChild(map, 0, kTagTileMap); CCSize s = map.ContentSize; map.Position = new CCPoint(-s.Width / 2, 0); // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you // can use any CCSprite and it will work OK. CCTMXLayer layer = map.LayerNamed("Trees"); m_tamara = layer.TileAt(new CCPoint(29, 29)); CCMoveBy move = new CCMoveBy (10, new CCPoint(300, 250) * (1f / CCMacros.CCContentScaleFactor())); CCFiniteTimeAction back = move.Reverse(); CCSequence seq = CCSequence.FromActions(move, back); m_tamara.RunAction(new CCRepeatForever (seq)); m_tamara.Position = new CCPoint(m_tamara.Position.X + 100, m_tamara.Position.Y + 100); Schedule(repositionSprite); }
public override void OnEnter() { base.OnEnter(); centerSprites(0); var spr = new CCSprite("Images/grossini"); spr.Position = new CCPoint(100, 100); AddChild(spr); var act1 = new CCMoveBy (0.5f, new CCPoint(100, 0)); var act2 = (CCMoveBy) act1.Reverse(); var act3 = CCSequence.FromActions(act1, act2); var act4 = new CCRepeat (act3, 2); spr.RunAction(act4); }
public override void OnEnter() { base.OnEnter(); centerSprites(3); var s = CCDirector.SharedDirector.WinSize; var actionTo = new CCMoveTo (2, new CCPoint(s.Width - 40, s.Height - 40)); var actionBy = new CCMoveBy (2, new CCPoint(80, 80)); var actionByBack = actionBy.Reverse(); m_tamara.RunAction(actionTo); m_grossini.RunAction(CCSequence.FromActions(actionBy, actionByBack)); m_kathia.RunAction(new CCMoveTo (1, new CCPoint(40, 40))); }
public override void OnEnter() { base.OnEnter(); m_background.Parent.RemoveChild(m_background, true); m_background = null; CCParallaxNode p = CCParallaxNode.Create(); 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 = CCParticleFlower.Create(); m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire); p1.AddChild(m_emitter, 10); m_emitter.Position = new CCPoint(250, 200); CCParticleSun par = CCParticleSun.Create(); 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)); }
public override void OnEnter() { // todo : CCOrbitCamera hasn't been implement base.OnEnter(); centerSprites(3); var orbit1 = new CCOrbitCamera(2, 1, 0, 0, 180, 0, 0); var action1 = CCSequence.FromActions(orbit1,orbit1.Reverse()); var orbit2 = new CCOrbitCamera(2, 1, 0, 0, 180, -45, 0); var action2 = CCSequence.FromActions(orbit2, orbit2.Reverse()); var orbit3 = new CCOrbitCamera(2, 1, 0, 0, 180, 90, 0); var action3 = CCSequence.FromActions(orbit3, orbit3.Reverse()); m_kathia.RunAction(new CCRepeatForever (action1)); m_tamara.RunAction(new CCRepeatForever (action2)); m_grossini.RunAction(new CCRepeatForever (action3)); var move = new CCMoveBy (3, new CCPoint(100, -100)); var move_back = move.Reverse(); var seq = CCSequence.FromActions(move, move_back); var rfe = new CCRepeatForever (seq); m_kathia.RunAction(rfe); m_tamara.RunAction((CCAction) (rfe.Copy())); m_grossini.RunAction((CCAction) (rfe.Copy())); }
public override void OnEnter() { base.OnEnter(); alignSpritesLeft(2); // Test: // Sequence should work both with IntervalAction and InstantActions var move1 = new CCMoveBy (1, new CCPoint(250, 0)); var move2 = new CCMoveBy (1, new CCPoint(0, 50)); var tog1 = new CCToggleVisibility(); var tog2 = new CCToggleVisibility(); var seq = CCSequence.FromActions(move1, tog1, move2, tog2, move1.Reverse()); var action = new CCRepeat ((CCSequence.FromActions(seq, seq.Reverse())), 3); // Test: // Also test that the reverse of Hide is Show, and vice-versa m_kathia.RunAction(action); var move_tamara = new CCMoveBy (1, new CCPoint(100, 0)); var move_tamara2 = new CCMoveBy (1, new CCPoint(50, 0)); var hide = new CCHide(); var seq_tamara = CCSequence.FromActions(move_tamara, hide, move_tamara2); var seq_back = seq_tamara.Reverse(); m_tamara.RunAction(CCSequence.FromActions(seq_tamara, seq_back)); }
public override void OnEnter() { base.OnEnter(); alignSpritesLeft(1); var move1 = new CCMoveBy (1, new CCPoint(250, 0)); var move2 = new CCMoveBy (1, new CCPoint(0, 50)); var seq = CCSequence.FromActions(move1, move2, move1.Reverse()); var action = CCSequence.FromActions(seq, seq.Reverse()); m_grossini.RunAction(action); }
public override void OnEnter() { base.OnEnter(); alignSpritesLeft(2); var a1 = new CCMoveBy (1, new CCPoint(150, 0)); var action1 = new CCRepeat ( CCSequence.FromActions(new CCPlace(new CCPoint(60, 60)), a1), 3); var action2 = new CCRepeatForever ( (CCSequence.FromActions((CCActionInterval) (a1.Copy()), a1.Reverse())) ); m_kathia.RunAction(action1); m_tamara.RunAction(action2); }