public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var move = new CCMoveBy(3, new CCPoint(s.Width - 130, 0)); var move_back = move.Reverse(); var move_ease_in = new CCEaseBackIn(move); var move_ease_in_back = move_ease_in.Reverse(); var move_ease_out = new CCEaseBackOut(move); var move_ease_out_back = move_ease_out.Reverse(); var delay = new CCDelayTime(0.25f); var seq1 = new CCSequence(move, delay, move_back, delay); var seq2 = new CCSequence(move_ease_in, delay, move_ease_in_back, delay); var seq3 = new CCSequence(move_ease_out, delay, move_ease_out_back, delay); m_grossini.RunAction(new CCRepeatForever(seq1)); m_tamara.RunAction(new CCRepeatForever(seq2)); m_kathia.RunAction(new CCRepeatForever(seq3)); }
public override void onEnter() { base.onEnter(); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(350, 0)); CCActionInterval move_ease_inout1 = CCEaseInOut.actionWithAction(move.copy() as CCActionInterval, 2.0f); CCActionInterval move_ease_inout_back1 = move_ease_inout1.reverse() as CCActionInterval; CCActionInterval move_ease_inout2 = CCEaseInOut.actionWithAction(move.copy() as CCActionInterval, 3.0f); CCActionInterval move_ease_inout_back2 = move_ease_inout2.reverse() as CCActionInterval; CCActionInterval move_ease_inout3 = CCEaseInOut.actionWithAction(move.copy() as CCActionInterval, 4.0f); CCActionInterval move_ease_inout_back3 = move_ease_inout3.reverse() as CCActionInterval; CCFiniteTimeAction seq1 = CCSequence.actions(move_ease_inout1, move_ease_inout_back1); CCFiniteTimeAction seq2 = CCSequence.actions(move_ease_inout2, move_ease_inout_back2); CCFiniteTimeAction seq3 = CCSequence.actions(move_ease_inout3, move_ease_inout_back3); m_tamara.runAction(CCRepeatForever.actionWithAction(seq1 as CCActionInterval)); m_kathia.runAction(CCRepeatForever.actionWithAction(seq2 as CCActionInterval)); m_grossini.runAction(CCRepeatForever.actionWithAction(seq3 as CCActionInterval)); }
public TMXIsoZorder() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-zorder"); addChild(map, 0, 1); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); map.position = (new CCPoint(-s.width / 2, 0)); m_tamara = CCSprite.spriteWithFile(s_pPathSister1); map.addChild(m_tamara, map.children.Count); int mapWidth = (int)(map.MapSize.width * map.TileSize.width); m_tamara.positionInPixels = new CCPoint(mapWidth / 2, 0); m_tamara.anchorPoint = new CCPoint(0.5f, 0); CCActionInterval move = CCMoveBy.actionWithDuration(10, new CCPoint(300 * 1 / CCDirector.sharedDirector().ContentScaleFactor, 250 * 1 / CCDirector.sharedDirector().ContentScaleFactor)); CCActionInterval back = (CCActionInterval)move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, back); m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); schedule((this.repositionSprite)); }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var move = new CCMoveBy(3, new CCPoint(s.Width - 130, 0)); var move_ease_inout1 = new CCEaseElasticInOut(move, 0.3f); var move_ease_inout_back1 = move_ease_inout1.Reverse(); var move_ease_inout2 = new CCEaseElasticInOut(move, 0.45f); var move_ease_inout_back2 = move_ease_inout2.Reverse(); var move_ease_inout3 = new CCEaseElasticInOut(move, 0.6f); var move_ease_inout_back3 = move_ease_inout3.Reverse(); var delay = new CCDelayTime(0.25f); var seq1 = new CCSequence(move_ease_inout1, delay, move_ease_inout_back1, delay); var seq2 = new CCSequence(move_ease_inout2, delay, move_ease_inout_back2, delay); var seq3 = new CCSequence(move_ease_inout3, delay, move_ease_inout_back3, delay); m_tamara.RunAction(new CCRepeatForever(seq1)); m_kathia.RunAction(new CCRepeatForever(seq2)); m_grossini.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_in = new CCEaseBackIn((CCActionInterval)(move.Copy())); var move_ease_in_back = move_ease_in.Reverse(); var move_ease_out = new CCEaseBackOut((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 NodeToWorld() { // // This code tests that nodeToParent works OK: // - It tests different anchor Points // - It tests different children anchor points CCSprite back = CCSprite.spriteWithFile(TestResource.s_back3); addChild(back, -10); back.anchorPoint = (new CCPoint(0, 0)); CCSize backSize = back.contentSize; CCMenuItem item = CCMenuItemImage.itemFromNormalImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect); CCMenu menu = CCMenu.menuWithItems(item); menu.alignItemsVertically(); menu.position = (new CCPoint(backSize.width / 2, backSize.height / 2)); back.addChild(menu); CCActionInterval rot = CCRotateBy.actionWithDuration(5, 360); CCAction fe = CCRepeatForever.actionWithAction(rot); item.runAction(fe); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(200, 0)); CCActionInterval move_back = (CCActionInterval)move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); CCAction fe2 = CCRepeatForever.actionWithAction((CCActionInterval)seq); back.runAction(fe2); }
public override void OnEnter() { base.OnEnter(); var s = CCDirector.SharedDirector.WinSize; var move = new CCMoveBy(3, new CCPoint(s.Width - 130, 0)); var move_ease_inout1 = new CCEaseElasticInOut((CCActionInterval)(move.Copy()), 0.3f); var move_ease_inout_back1 = move_ease_inout1.Reverse(); var move_ease_inout2 = new CCEaseElasticInOut((CCActionInterval)(move.Copy()), 0.45f); var move_ease_inout_back2 = move_ease_inout2.Reverse(); var move_ease_inout3 = new CCEaseElasticInOut((CCActionInterval)(move.Copy()), 0.6f); var move_ease_inout_back3 = move_ease_inout3.Reverse(); var delay = new CCDelayTime(0.25f); var seq1 = CCSequence.FromActions(move_ease_inout1, delay, move_ease_inout_back1, (CCFiniteTimeAction)delay.Copy()); var seq2 = CCSequence.FromActions(move_ease_inout2, (CCFiniteTimeAction)delay.Copy(), move_ease_inout_back2, (CCFiniteTimeAction)delay.Copy()); var seq3 = CCSequence.FromActions(move_ease_inout3, (CCFiniteTimeAction)delay.Copy(), move_ease_inout_back3, (CCFiniteTimeAction)delay.Copy()); m_tamara.RunAction(new CCRepeatForever(seq1)); m_kathia.RunAction(new CCRepeatForever(seq2)); m_grossini.RunAction(new CCRepeatForever(seq3)); }
public GameLayer() : base(CCColor4B.Blue, CCColor4B.AliceBlue) { // Set the layer gradient direction this.Vector = new CCPoint(0.5f, 0.5f); // Create and add sprites // We will later be applying a wave action to these sprites // These type of actions can only be applied to CCNodeGrid instances // Therefore, wrap our sprites in a CCNodeGrid parent monkeySprite1 = new CCNodeGrid(); monkeySprite1.AddChild(new CCSprite("monkey")); AddChild(monkeySprite1); monkeySprite2 = new CCNodeGrid(); monkeySprite2.AddChild(new CCSprite("monkey")); AddChild(monkeySprite2); // Define actions var moveUp = new CCMoveBy(1.0f, new CCPoint(0.0f, 50.0f)); var moveDown = moveUp.Reverse(); // A CCSequence action runs the list of actions in ... sequence! CCSequence moveSeq = new CCSequence(new CCEaseBackInOut(moveUp), new CCEaseBackInOut(moveDown)); repeatedAction = new CCRepeatForever(moveSeq); // A CCSpawn action runs the list of actions concurrently dreamAction = new CCSpawn(new CCFadeIn(5.0f), new CCWaves(5.0f, new CCGridSize(10, 20), 4, 4)); // Schedule for method to be called every 0.1s Schedule(UpdateLayerGradient, 0.1f); }
public override void onEnter() { base.onEnter(); m_background.parent.removeChild(m_background, true); m_background = null; CCParallaxNode p = CCParallaxNode.node(); addChild(p, 5); CCSprite p1 = CCSprite.spriteWithFile(TestResource.s_back3); CCSprite p2 = CCSprite.spriteWithFile(TestResource.s_back3); p.addChild(p1, 1, new CCPoint(0.5f, 1), new CCPoint(0, 0)); p.addChild(p2, 2, new CCPoint(1.5f, 1), new CCPoint(0, 0)); m_emitter = CCParticleFlower.node(); m_emitter.Texture = CCTextureCache.sharedTextureCache().addImage(TestResource.s_fire); p1.addChild(m_emitter, 10); m_emitter.position = new CCPoint(250, 200); CCParticleSun par = CCParticleSun.node(); p2.addChild(par, 10); par.Texture = CCTextureCache.sharedTextureCache().addImage(TestResource.s_fire); CCActionInterval move = CCMoveBy.actionWithDuration(4, new CCPoint(300, 0)); CCFiniteTimeAction move_back = move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); p.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); }
public override void onEnter() { base.onEnter(); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(350, 0)); CCActionInterval move_back = (CCActionInterval)move.reverse(); CCActionInterval move_ease_in = CCEaseIn.actionWithAction(move.copy() as CCActionInterval, 3); CCActionInterval move_ease_in_back = move_ease_in.reverse() as CCActionInterval; CCActionInterval move_ease_out = CCEaseOut.actionWithAction(move.copy() as CCActionInterval, 3); CCActionInterval move_ease_out_back = move_ease_out.reverse() as CCActionInterval; CCFiniteTimeAction seq1 = CCSequence.actions(move, move_back); CCFiniteTimeAction seq2 = CCSequence.actions(move_ease_in, move_ease_in_back); CCFiniteTimeAction seq3 = CCSequence.actions(move_ease_out, move_ease_out_back); CCAction a2 = m_grossini.runAction(CCRepeatForever.actionWithAction(seq1 as CCActionInterval)); a2.tag = 1; CCAction a1 = m_tamara.runAction(CCRepeatForever.actionWithAction(seq2 as CCActionInterval)); a1.tag = 1; CCAction a = m_kathia.runAction(CCRepeatForever.actionWithAction(seq3 as CCActionInterval)); a.tag = 1; schedule(new SEL_SCHEDULE(testStopAction), 6.0f); }
public StressTest2() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCLayer sublayer = CCLayer.node(); CCSprite sp1 = CCSprite.spriteWithFile(TestResource.s_pPathSister1); sp1.position = (new CCPoint(80, s.height / 2)); CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(350, 0)); CCActionInterval move_ease_inout3 = CCEaseInOut.actionWithAction((CCActionInterval)(move.copy()), 2.0f); CCActionInterval move_ease_inout_back3 = (CCActionInterval)move_ease_inout3.reverse(); CCFiniteTimeAction seq3 = CCSequence.actions(move_ease_inout3, move_ease_inout_back3); sp1.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq3)); sublayer.addChild(sp1, 1); CCParticleFire fire = CCParticleFire.node(); fire.Texture = (CCTextureCache.sharedTextureCache().addImage("Images/fire")); fire.position = (new CCPoint(80, s.height / 2 - 50)); CCActionInterval copy_seq3 = (CCActionInterval)(seq3.copy()); fire.runAction(CCRepeatForever.actionWithAction(copy_seq3)); sublayer.addChild(fire, 2); schedule((shouldNotLeak), 6.0f); addChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1); }
public TMXIsoVertexZ() { CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-vertexz"); addChild(map, 0, 1); CCSize s = map.contentSize; map.position = new CCPoint(-s.width / 2, 0); ////----UXLOG("ContentSize: %f, %f", s.width,s.height); // 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)); CCActionInterval move = CCMoveBy.actionWithDuration(10, new CCPoint(300 * 1 / CCDirector.sharedDirector().ContentScaleFactor, 250 * 1 / CCDirector.sharedDirector().ContentScaleFactor)); CCActionInterval back = (CCActionInterval)move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, back); m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); schedule(repositionSprite); }
public GameLayer() : base(CCColor4B.Blue, CCColor4B.AliceBlue) { // Set the layer gradient direction this.Vector = new CCPoint(0.5f, 0.5f); // Create and add sprites monkeySprite1 = new CCSprite("monkey"); AddChild(monkeySprite1, 1); monkeySprite2 = new CCSprite("monkey"); AddChild(monkeySprite2, 1); // Define actions var moveUp = new CCMoveBy(1.0f, new CCPoint(0.0f, 50.0f)); var moveDown = moveUp.Reverse(); // A CCSequence action runs the list of actions in ... sequence! CCSequence moveSeq = new CCSequence(new CCEaseBackInOut(moveUp), new CCEaseBackInOut(moveDown)); repeatedAction = new CCRepeatForever(moveSeq); // A CCSpawn action runs the list of actions concurrently dreamAction = new CCSpawn(new CCFadeIn(5.0f), new CCWaves(5.0f, new CCGridSize(10, 20), 4, 4)); // Schedule for method to be called every 0.1s Schedule(UpdateLayerGradient, 0.1f); }
public override void onEnter() { base.onEnter(); alignSpritesLeft(2); // Test: // Sequence should work both with IntervalAction and InstantActions CCActionInterval move1 = CCMoveBy.actionWithDuration(1, new CCPoint(250, 0)); CCActionInterval move2 = CCMoveBy.actionWithDuration(1, new CCPoint(0, 50)); CCToggleVisibility tog1 = new CCToggleVisibility(); CCToggleVisibility tog2 = new CCToggleVisibility(); CCFiniteTimeAction seq = CCSequence.actions(move1, tog1, move2, tog2, move1.reverse()); CCActionInterval action = CCRepeat.actionWithAction((CCActionInterval)(CCSequence.actions(seq, seq.reverse())), 3); // Test: // Also test that the reverse of Hide is Show, and vice-versa m_kathia.runAction(action); CCActionInterval move_tamara = CCMoveBy.actionWithDuration(1, new CCPoint(100, 0)); CCActionInterval move_tamara2 = CCMoveBy.actionWithDuration(1, new CCPoint(50, 0)); CCActionInstant hide = new CCHide(); CCFiniteTimeAction seq_tamara = CCSequence.actions(move_tamara, hide, move_tamara2); CCFiniteTimeAction seq_back = seq_tamara.reverse(); m_tamara.runAction(CCSequence.actions(seq_tamara, seq_back)); }
public override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); // the root object just rotates around m_root = CCSprite.spriteWithFile(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 = CCSprite.spriteWithFile(s_pPathR1); m_root.addChild(m_target); m_target.position = (new CCPoint(100, 0)); // create the streak object and add it to the scene //m_streak = CCMotionStreak.streakWithFade(2, 3, s_streak, 32, 32, new ccColor4B(0,255,0,255) ); addChild(m_streak); // schedule an update on each frame so we can syncronize the streak with the target schedule(onUpdate); CCActionInterval a1 = CCRotateBy.actionWithDuration(2, 360); CCAction action1 = CCRepeatForever.actionWithAction(a1); CCActionInterval motion = CCMoveBy.actionWithDuration(2, new CCPoint(100, 0)); m_root.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(motion, motion.reverse())))); m_root.runAction(action1); }
public StressTest2() { CCSize s = CCDirector.SharedDirector.WinSize; CCLayer sublayer = new CCLayer(); CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); sp1.Position = (new CCPoint(80, s.Height / 2)); CCActionInterval move = new CCMoveBy(3, new CCPoint(350, 0)); CCActionInterval move_ease_inout3 = new CCEaseInOut((CCActionInterval)(move.Copy()), 2.0f); var move_ease_inout_back3 = (CCActionInterval)move_ease_inout3.Reverse(); CCFiniteTimeAction seq3 = CCSequence.FromActions(move_ease_inout3, move_ease_inout_back3); sp1.RunAction(new CCRepeatForever((CCActionInterval)seq3)); sublayer.AddChild(sp1, 1); CCParticleFire fire = new CCParticleFire(); fire.Texture = (CCTextureCache.SharedTextureCache.AddImage("Images/fire")); fire.Position = (new CCPoint(80, s.Height / 2 - 50)); var copy_seq3 = (CCActionInterval)(seq3.Copy()); fire.RunAction(new CCRepeatForever(copy_seq3)); sublayer.AddChild(fire, 2); Schedule((shouldNotLeak), 6.0f); AddChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1); }
public static new CCMoveBy actionWithDuration(float duration, CCPoint position) { CCMoveBy ret = new CCMoveBy(); ret.initWithDuration(duration, position); return ret; }
public override void onEnter() { // // This test MUST be done in 'onEnter' and not on 'init' // otherwise the paused action will be resumed at 'onEnter' time // base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF l = CCLabelTTF.labelWithString("After 5 seconds grossini should move", "Arial", 16); addChild(l); l.position = (new CCPoint(s.width / 2, 245)); // // Also, this test MUST be done, after [super onEnter] // CCSprite grossini = CCSprite.spriteWithFile(s_pPathGrossini); addChild(grossini, 0, kTagGrossini); grossini.position = (new CCPoint(200, 200)); CCAction action = CCMoveBy.actionWithDuration(1, new CCPoint(150, 0)); CCActionManager.sharedManager().addAction(action, grossini, true); schedule(unpause, 3); }
public override void OnEnter() { base.OnEnter(); Color = CCColor3B.Blue; Opacity = 255; // Make sure we set the Opacity to cascade or fadein action will not work correctly. Target1.IsOpacityCascaded = true; Target2.IsOpacityCascaded = true; // Define actions var moveUp = new CCMoveBy(1.0f, new CCPoint(0.0f, 50.0f)); var moveDown = moveUp.Reverse(); // A CCSequence action runs the list of actions in ... sequence! var moveSeq = new CCSequence(new CCEaseBackInOut(moveUp), new CCEaseBackInOut(moveDown)); var repeatedAction = new CCRepeatForever(moveSeq); // A CCSpawn action runs the list of actions concurrently var dreamAction = new CCSpawn(new CCFadeIn(5.0f), new CCWaves(5.0f, new CCGridSize(10, 20), 5, 20, true, false)); Target1.RunActions(dreamAction, repeatedAction); Target2.RunActions(dreamAction, new CCDelayTime(0.5f), repeatedAction); // moving background. Testing issue #244 var move = new CCMoveBy(3, new CCPoint(200, 0)); bgNode.RepeatForever(move, move.Reverse()); }
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 GameScoresLayer() { var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesBegan = (touches, ccevent) => { var mainGame = GameStartLayer.CreateScene(Window); var transitionToGameOver = new CCTransitionMoveInL(0.3f, mainGame); Director.ReplaceScene(transitionToGameOver); }; AddEventListener(touchListener, this); scoreMessage = String.Format("Current High Score"); Color = new CCColor3B(127, 200, 205); Opacity = 255; var moveUp = new CCMoveBy(1.0f, new CCPoint(0.0f, 50.0f)); var moveDown = moveUp.Reverse(); // A CCSequence action runs the list of actions in ... sequence! CCSequence moveSeq = new CCSequence(new CCEaseBackInOut(moveUp), new CCEaseBackInOut(moveDown)); repeatedAction = new CCRepeatForever(moveSeq); }
public override void OnEnter() { base.OnEnter(); centerSprites(0); var spr = new CCSprite("Images/grossini"); spr.Position = new CCPoint(200, 200); AddChild(spr); var act1 = new CCMoveBy(2, new CCPoint(0, 100)); var act2 = new CCCallFunc(log1); var act3 = new CCMoveBy(2, new CCPoint(0, -100)); var act4 = new CCCallFunc(log2); var act5 = new CCMoveBy(2, new CCPoint(100, -100)); var act6 = new CCCallFunc(log3); var act7 = new CCMoveBy(2, new CCPoint(-100, 0)); var act8 = new CCCallFunc(log4); var actF = CCSequence.FromActions(act1, act2, act3, act4, act5, act6, act7, act8); CCDirector.SharedDirector.ActionManager.AddAction(actF, spr, false); }
public override void OnEnter() { // // This test MUST be done in 'onEnter' and not on 'init' // otherwise the paused action will be resumed at 'onEnter' time // base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; CCLabelTtf l = new CCLabelTtf("After 5 seconds grossini should move", "arial", 16); AddChild(l); l.Position = (new CCPoint(s.Width / 2, 245)); // // Also, this test MUST be done, after [super onEnter] // CCSprite grossini = new CCSprite(s_pPathGrossini); AddChild(grossini, 0, kTagGrossini); grossini.Position = (new CCPoint(200, 200)); CCAction action = new CCMoveBy(1, new CCPoint(150, 0)); grossini.AddAction(action, true); Schedule(unpause, 3); }
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() { // 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 CCObject copyWithZone(CCZone zone) { CCZone tmpZone = zone; CCMoveBy ret = null; if (tmpZone != null && tmpZone.m_pCopyObject != null) { ret = tmpZone.m_pCopyObject as CCMoveBy; if (ret == null) { return null; } } else { ret = new CCMoveBy(); tmpZone = new CCZone(ret); } base.copyWithZone(tmpZone); ret.initWithDuration(m_fDuration, m_delta); return ret; }
public override CCObject copyWithZone(CCZone zone) { CCZone tmpZone = zone; CCMoveBy ret = null; if (tmpZone != null && tmpZone.m_pCopyObject != null) { ret = tmpZone.m_pCopyObject as CCMoveBy; if (ret == null) { return(null); } } else { ret = new CCMoveBy(); tmpZone = new CCZone(ret); } base.copyWithZone(tmpZone); ret.initWithDuration(m_fDuration, m_delta); return(ret); }
void MoveClouds(float dy) { parallaxClouds.StopAllActions(); var moveClouds = new CCMoveBy(1.0f, new CCPoint(0, dy * 0.1f)); parallaxClouds.RunAction(moveClouds); }
protected override void AddedToScene() { base.AddedToScene(); var s = VisibleBoundsWorldspace.Size; var left = new CCPoint(s.Width / 4, s.Height / 2); var right = new CCPoint(s.Width / 4 * 3, s.Height / 2); var sp1 = new CCSprite("Images/grossini.png"); sp1.Position = new CCPoint(left); var move1 = new CCMoveBy(1, new CCPoint(s.Width / 2, 0)); AddChild(sp1); sp1.RepeatForever(move1, move1.Reverse()); var sp2 = new CCSprite("Images/grossinis_sister1.png"); sp2.Position = new CCPoint(right); var move2 = new CCMoveBy(1, new CCPoint(-s.Width / 2, 0)); AddChild(sp2); sp2.RepeatForever(move2, move2.Reverse()); var label1 = new CCLabel("capture all", "fonts/arial", 24, CCLabelFormat.SpriteFont); var mi1 = new CCMenuItemLabel(label1, OnCapture); var menu = new CCMenu(mi1); AddChild(menu); menu.Position = new CCPoint(s.Width / 2, s.Height / 4); }
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 StressTest2() { var sublayer = new CCLayer(); var sp1 = new CCSprite(TestResource.s_pPathSister1); var move = new CCMoveBy(3, new CCPoint(350, 0)); var move_ease_inout3 = new CCEaseInOut(move, 2.0f); var move_ease_inout_back3 = move_ease_inout3.Reverse(); var seq3 = new CCSequence(move_ease_inout3, move_ease_inout_back3); sp1.RepeatForever(seq3); sublayer.AddChild(sp1, 1, CocosNodeTestStaticLibrary.kTagSprite2); var fire = new CCParticleFire(CCPoint.Zero) { Tag = CocosNodeTestStaticLibrary.kTagSprite3 }; fire.Texture = (CCTextureCache.SharedTextureCache.AddImage("Images/fire")); fire.RepeatForever(seq3); sublayer.AddChild(fire, 2); Schedule(shouldNotLeak, 6.0f); AddChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1); }
public ParticleDemo() { initWithColor(ccTypes.ccc4(127, 127, 127, 255)); m_emitter = null; isTouchEnabled = true; CCSize s = CCDirector.sharedDirector().getWinSize(); CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28); addChild(label, 100, 1000); label.position = new CCPoint(s.width / 2, s.height - 50); CCLabelTTF tapScreen = CCLabelTTF.labelWithString("(Tap the Screen)", "Arial", 20); tapScreen.position = new CCPoint(s.width / 2, s.height - 80); addChild(tapScreen, 100); CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathB1, TestResource.s_pPathB2, this, new SEL_MenuHandler(backCallback)); CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, new SEL_MenuHandler(restartCallback)); CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, new SEL_MenuHandler(nextCallback)); CCMenuItemToggle item4 = CCMenuItemToggle.itemWithTarget(this, new SEL_MenuHandler(toggleCallback), CCMenuItemFont.itemFromString("Free Movement"), CCMenuItemFont.itemFromString("Relative Movement"), CCMenuItemFont.itemFromString("Grouped Movement")); CCMenu menu = CCMenu.menuWithItems(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 = CCLabelAtlas.labelWithString("0000", "fonts/fnt/images/fps_images", 16, 24, '.'); addChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas); labelAtlas.position = new CCPoint(s.width - 66, 50); // moving background m_background = CCSprite.spriteWithFile(TestResource.s_back3); addChild(m_background, 5); m_background.position = new CCPoint(s.width / 2 - 120, s.height - 240); CCActionInterval move = CCMoveBy.actionWithDuration(4, new CCPoint(300, 0)); CCFiniteTimeAction move_back = move.reverse(); CCFiniteTimeAction seq = CCSequence.actions(move, move_back); m_background.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq)); schedule(new SEL_SCHEDULE(step)); }
protected CCMoveBy (CCMoveBy moveBy) : base (moveBy) { InitWithDuration (moveBy.m_fDuration, moveBy.m_delta); }
public CCMoveByState (CCMoveBy action, CCNode target) : base (action, target) { PositionDelta = action.PositionDelta; PreviousPosition = StartPosition = target.Position; }