public override void OnEnter() { base.OnEnter(); CCSize winSize = Layer.VisibleBoundsWorldspace.Size; float x = winSize.Width / 2; float y = 0 + (winSize.Height / 2); var rgba = new CCLayer(); rgba.IsColorCascaded = true; rgba.IsOpacityCascaded = true; AddChild(rgba); CCLog.Log("S9CascadeOpacityAndColor ..."); var blocks_scaled_with_insets = CCScale9Sprite.SpriteWithFrameName("blocks9r.png"); CCLog.Log("... created"); blocks_scaled_with_insets.Position = new CCPoint(x, y); CCLog.Log("... setPosition"); rgba.AddChild(blocks_scaled_with_insets); var actions = new CCSequence(new CCFadeIn(1), new CCTintTo(1, 0, 255, 0), new CCTintTo(1, 255, 255, 255), new CCFadeOut(1)); var repeat = new CCRepeatForever(actions); rgba.RunAction(repeat); CCLog.Log("AddChild"); CCLog.Log("... S9CascadeOpacityAndColor done."); }
public Test6() { CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp11 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2); CCSprite sp21 = new CCSprite(TestResource.s_pPathSister2); sp1.Position = (new CCPoint(100, 160)); sp2.Position = (new CCPoint(380, 160)); CCFiniteTimeAction rot = new CCRotateBy(2, 360); var rot_back = rot.Reverse(); var forever1 = new CCRepeatForever(rot, rot_back); AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1); sp1.AddChild(sp11); AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2); sp2.AddChild(sp21); sp1.RunAction(forever1); sp11.RunAction(forever1); sp2.RunAction(forever1); sp21.RunAction(forever1); Schedule(addAndRemove, 2.0f); }
void MoveClouds() { if ((windSpeedChanged == true) && (windSpeed > 0)) { CCRepeatForever cloudsAnimation; float targetPositionX = (windBlowingRight == true ? layerWidth + 350 : -350f); CCSequence cloudsMovingSequence = new CCSequence(new CCMoveBy(0, new CCPoint(0, 0))); CCMoveTo moveAcrossTo = new CCMoveTo(windSpeed * 3f, new CCPoint(targetPositionX, cloudsParallax.PositionY)); CCEaseSineIn easeInAcrossTo = new CCEaseSineIn(moveAcrossTo); cloudsMovingSequence = new CCSequence(moveAcrossTo, new CCCallFunc(() => cloudsParallax.PositionX = (windBlowingRight == true ? -350f : layerWidth + 350))); cloudsAnimation = new CCRepeatForever(cloudsMovingSequence); cloudsParallax.StopAllActions(); cloudsParallax.RunActions(easeInAcrossTo, cloudsAnimation); } else if (windSpeed < float.Epsilon) { float targetPositionX = (windBlowingRight == true ? previousWindSpeed * 7 : previousWindSpeed * -7); CCEaseSineOut easeOutBy = new CCEaseSineOut(new CCMoveBy(previousWindSpeed * 1.2f, new CCPoint(targetPositionX, 0))); cloudsParallax.StopAllActions(); cloudsParallax.RunAction(easeOutBy); } }
public override void OnEnter() { base.OnEnter(); CCSize winSize = CCDirector.SharedDirector.WinSize; float x = winSize.Width / 2; float y = 0 + (winSize.Height / 2); var rgba = new CCLayerRGBA(); rgba.CascadeColorEnabled = true; rgba.CascadeOpacityEnabled = true; AddChild(rgba); CCLog.Log("S9CascadeOpacityAndColor ..."); var blocks_scaled_with_insets = new CCScale9Sprite(); blocks_scaled_with_insets.InitWithSpriteFrameName("blocks9r.png"); CCLog.Log("... created"); blocks_scaled_with_insets.Position = new CCPoint(x, y); CCLog.Log("... setPosition"); rgba.AddChild(blocks_scaled_with_insets); var actions = new CCSequence(new CCFadeIn(1), new CCTintTo(1, 0, 255, 0), new CCTintTo(1, 255, 255, 255), new CCFadeOut(1)); var repeat = new CCRepeatForever(actions); rgba.RunAction(repeat); CCLog.Log("AddChild"); CCLog.Log("... S9CascadeOpacityAndColor done."); }
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(); 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 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 Test5() { CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); sp2 = new CCSprite(TestResource.s_pPathSister2); sp1.Position = (new CCPoint(100, 160)); sp2.Position = (new CCPoint(380, 160)); CCRotateBy rot = new CCRotateBy(2, 360); var rot_back = rot.Reverse() as CCActionInterval; CCAction forever = new CCRepeatForever((CCActionInterval) new CCSequence(rot, rot_back)); forever2 = (CCAction)(forever.Copy()); forever.Tag = (101); forever2.Tag = (102); AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1); AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2); RemoveChild(sp2, true); AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2); // Sprite 1 should run and run // Sprite 2 should stop sp1.RunAction(forever); sp2.RunAction(forever2); // Experiment with removing sp2 and re-adding it after cleanup to reproduce an error in child management // ScheduleOnce(Stage2OfTest, 2.0f); Schedule(addAndRemove, 2.0f); }
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 LabelAtlasColorTest() { CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label1, 0, (int)TagSprite.kTagSprite1); label1.Position = new CCPoint(10, 100); label1.Opacity = 200; CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label2, 0, (int)TagSprite.kTagSprite2); label2.Position = new CCPoint(10, 200); label2.Color = ccRED; CCActionInterval fade = new CCFadeOut(1.0f); CCFiniteTimeAction fade_in = fade.Reverse(); CCFiniteTimeAction seq = new CCSequence(fade, fade_in); CCAction repeat = new CCRepeatForever((CCActionInterval)seq); label2.RunAction(repeat); m_time = 0; Schedule(step); //:@selector(step:)]; }
public override void onEnter() { base.onEnter(); // rotate and jump CCActionInterval jump1 = CCJumpBy.actionWithDuration(4, new CCPoint(-400, 0), 100, 4); CCActionInterval jump2 = jump1.reverse() as CCActionInterval; CCActionInterval rot1 = CCRotateBy.actionWithDuration(4, 360 * 2); CCActionInterval rot2 = rot1.reverse() as CCActionInterval; CCFiniteTimeAction seq3_1 = CCSequence.actions(jump2, jump1); CCFiniteTimeAction seq3_2 = CCSequence.actions(rot1, rot2); CCFiniteTimeAction spawn = CCSpawn.actions(seq3_1, seq3_2); CCFiniteTimeAction action = CCRepeatForever.actionWithAction((CCActionInterval)spawn); CCRepeatForever action2 = (CCRepeatForever)(action.copy()); CCRepeatForever action3 = (CCRepeatForever)(action.copy()); m_grossini.runAction(CCSpeed.actionWithAction((CCActionInterval)action, 0.5f)); m_tamara.runAction(CCSpeed.actionWithAction((CCActionInterval)action2, 1.5f)); m_kathia.runAction(CCSpeed.actionWithAction((CCActionInterval)action3, 1.0f)); CCParticleSystem emitter = CCParticleFireworks.node(); emitter.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire"); addChild(emitter); }
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 Layer3() : base(new ccColor4B (0,0,255,255)) { CGSize s = CCDirector.SharedDirector ().WinSize (); CCMenuItemFont item0 = new CCMenuItemFont("Touch to pushScene (self)", delegate { CCScene newScene = new CCScene(); newScene.AddChild (new Layer3 ()); CCDirector.SharedDirector ().PushScene (new CCTransitionFade (0.5f, newScene, new ccColor3B (0, 255, 255))); }); CCMenuItemFont item1 = new CCMenuItemFont("Touch to popScene", delegate { CCDirector.SharedDirector ().PopScene (); }); CCMenuItemFont item2 = new CCMenuItemFont("Touch to popToRootScene", delegate { CCDirector.SharedDirector ().PopToRootScene (); }); CCMenu menu = new CCMenu(item0, item1, item2); this.AddChild (menu); menu.AlignItemsVertically (); CCSprite sprite = new CCSprite("grossini.png", true); this.AddChild (sprite); sprite.Position = new CCPoint(s.Width / 2, 40); var rotate = new CCRotateBy (2, 360); var repeat = new CCRepeatForever (rotate); sprite.RunAction (repeat); }
public override void onEnter() { base.onEnter(); // rotate and jump CCActionInterval jump1 = CCJumpBy.actionWithDuration(4, new CCPoint(-400, 0), 100, 4); CCActionInterval jump2 = (CCActionInterval)jump1.reverse(); CCActionInterval rot1 = CCRotateBy.actionWithDuration(4, 360 * 2); CCActionInterval rot2 = (CCActionInterval)rot1.reverse(); CCFiniteTimeAction seq3_1 = CCSequence.actions(jump2, jump1); CCFiniteTimeAction seq3_2 = CCSequence.actions(rot1, rot2); CCFiniteTimeAction spawn = CCSpawn.actions(seq3_1, seq3_2); CCSpeed action = CCSpeed.actionWithAction(CCRepeatForever.actionWithAction((CCActionInterval)spawn), 1.0f); action.tag = EaseTest.kTagAction1; CCAction action2 = (CCAction)(action.copy()); CCAction action3 = (CCAction)(action.copy()); action2.tag = EaseTest.kTagAction1; action3.tag = EaseTest.kTagAction1; m_grossini.runAction(action2); //m_grossini.runAction(CCRepeat.actionWithAction(CCSequence.actions(jump2, jump1), 5)); m_tamara.runAction(action3); m_kathia.runAction(action); this.schedule(new SEL_SCHEDULE(altertime), 1.0f);//:@selector(altertime:) interval:1.0f]; }
private void performanceActions20(CCSprite pSprite) { CCSize size = CCDirector.SharedDirector.WinSize; if (CCRandom.Float_0_1() < 0.2f) { pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height)); } else { pSprite.Position = new CCPoint(-1000, -1000); } float period = 0.5f + (CCRandom.Next() % 1000) / 500.0f; CCRotateBy rot = new CCRotateBy(period, 360.0f * CCRandom.Float_0_1()); var rot_back = (CCActionInterval)rot.Reverse(); CCAction permanentRotation = new CCRepeatForever(new CCSequence(rot, rot_back)); pSprite.RunAction(permanentRotation); float growDuration = 0.5f + (CCRandom.Next() % 1000) / 500.0f; CCActionInterval grow = new CCScaleBy(growDuration, 0.5f, 0.5f); CCAction permanentScaleLoop = new CCRepeatForever(new CCSequence(grow, grow.Reverse())); pSprite.RunAction(permanentScaleLoop); }
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 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 Test6() { CCSprite sp1 = CCSprite.spriteWithFile(TestResource.s_pPathSister1); CCSprite sp11 = CCSprite.spriteWithFile(TestResource.s_pPathSister1); CCSprite sp2 = CCSprite.spriteWithFile(TestResource.s_pPathSister2); CCSprite sp21 = CCSprite.spriteWithFile(TestResource.s_pPathSister2); sp1.position = (CCF.CCPointMake(100, 160)); sp2.position = (CCF.CCPointMake(380, 160)); CCActionInterval rot = CCRotateBy.actionWithDuration(2, 360); CCActionInterval rot_back = rot.reverse() as CCActionInterval; CCAction forever1 = CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(rot, rot_back))); CCAction forever11 = (CCAction)(forever1.copy()); CCAction forever2 = (CCAction)(forever1.copy()); CCAction forever21 = (CCAction)(forever1.copy()); addChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1); sp1.addChild(sp11); addChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2); sp2.addChild(sp21); sp1.runAction(forever1); sp11.runAction(forever11); sp2.runAction(forever2); sp21.runAction(forever21); schedule(new SEL_SCHEDULE(this.addAndRemove), 2.0f); }
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 SceneTestLayer2() { m_timeCounter = 0; CCMenuItemFont item1 = new CCMenuItemFont("(2) replaceScene", onReplaceScene); CCMenuItemFont item2 = new CCMenuItemFont("(2) replaceScene w/transition", onReplaceSceneTran); CCMenuItemFont item3 = new CCMenuItemFont("(2) Go Back", onGoBack); _PopMenuItem = new CCMenuItemFont("(2) Test popScene w/transition", onPopSceneTran); _TheMenu = new CCMenu(item1, item2, item3, _PopMenuItem); _TheMenu.AlignItemsVertically(); AddChild(_TheMenu); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sprite = new CCSprite(s_pPathGrossini); AddChild(sprite); sprite.Position = new CCPoint(s.Width - 40, s.Height / 2); CCActionInterval rotate = new CCRotateBy(2, 360); CCAction repeat = new CCRepeatForever(rotate); sprite.RunAction(repeat); Schedule(testDealloc); }
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 = new CCSequence(move, move_back); CCAction fe2 = new CCRepeatForever((CCActionInterval)seq); back.RunAction(fe2); }
public LabelAtlasColorTest() { CCLabelAtlas label1 = CCLabelAtlas.labelWithString("123 Test", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' '); addChild(label1, 0, (int)TagSprite.kTagSprite1); label1.position = new CCPoint(10, 100); label1.Opacity = 200; CCLabelAtlas label2 = CCLabelAtlas.labelWithString("0123456789", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' '); addChild(label2, 0, (int)TagSprite.kTagSprite2); label2.position = new CCPoint(10, 200); label2.Color = ccRED; CCActionInterval fade = CCFadeOut.actionWithDuration(1.0f); CCFiniteTimeAction fade_in = fade.reverse(); CCFiniteTimeAction seq = CCSequence.actions(fade, fade_in); CCAction repeat = CCRepeatForever.actionWithAction((CCActionInterval)seq); label2.runAction(repeat); m_time = 0; schedule(step); //:@selector(step:)]; }
public Test6() { CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp11 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2); CCSprite sp21 = new CCSprite(TestResource.s_pPathSister2); sp1.Position = (new CCPoint(100, 160)); sp2.Position = (new CCPoint(380, 160)); CCActionInterval rot = new CCRotateBy(2, 360); var rot_back = rot.Reverse() as CCActionInterval; CCAction forever1 = new CCRepeatForever((CCActionInterval) new CCSequence(rot, rot_back)); var forever11 = (CCAction)(forever1.Copy()); var forever2 = (CCAction)(forever1.Copy()); var forever21 = (CCAction)(forever1.Copy()); AddChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1); sp1.AddChild(sp11); AddChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2); sp2.AddChild(sp21); sp1.RunAction(forever1); sp11.RunAction(forever11); sp2.RunAction(forever2); sp21.RunAction(forever21); Schedule(addAndRemove, 2.0f); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; var sp1 = new CCSprite(TestResource.s_pPathSister1); var sp2 = new CCSprite(TestResource.s_pPathSister2); var sp3 = new CCSprite(TestResource.s_pPathSister1); var sp4 = new CCSprite(TestResource.s_pPathSister2); sp1.Position = (new CCPoint(100, s.Height / 2)); sp2.Position = (new CCPoint(380, s.Height / 2)); AddChild(sp1); AddChild(sp2); sp3.Scale = (0.25f); sp4.Scale = (0.25f); sp1.AddChild(sp3); sp2.AddChild(sp4); var a1 = new CCRotateBy(2, 360); var a2 = new CCScaleBy(2, 2); var action1 = new CCRepeatForever(a1, a2, a2.Reverse()); sp2.AnchorPoint = (new CCPoint(0, 0)); sp1.RunAction(action1); sp2.RunAction(action1); }
public override void OnNodeLoaded(CCNode node, CCNodeLoader nodeLoader) { CCRotateBy ccRotateBy = new CCRotateBy(20.0f, 360); CCRepeatForever ccRepeatForever = new CCRepeatForever(ccRotateBy); mBurstSprite.RunAction(ccRepeatForever); }
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)); }
public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = CCDirector.sharedDirector().getWinSize(); // sun //CCParticleSystem sun = CCParticleSun.node(); //sun.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire"); //sun.position = (new CCPoint(s.width - 32, s.height - 32)); ////sun.setTotalParticles(130); //sun.Life = (0.6f); //this.addChild(sun); // timers m_label0 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label1 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label2 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label3 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); m_label4 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4"); base.scheduleUpdate(); schedule(step1); schedule(step2, 0); schedule(step3, 1.0f); schedule(step4, 2.0f); m_label1.position = new CCPoint(s.width * 2 / 6, s.height / 2); m_label2.position = new CCPoint(s.width * 3 / 6, s.height / 2); m_label3.position = new CCPoint(s.width * 4 / 6, s.height / 2); m_label4.position = new CCPoint(s.width * 5 / 6, s.height / 2); addChild(m_label0); addChild(m_label1); addChild(m_label2); addChild(m_label3); addChild(m_label4); // Sprite CCSprite sprite = CCSprite.spriteWithFile(s_pPathGrossini); sprite.position = new CCPoint(40, 50); CCJumpBy jump = CCJumpBy.actionWithDuration(3, new CCPoint(s.width - 80, 0), 50, 4); addChild(sprite); sprite.runAction(CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions(jump, jump.reverse())) ) ); // pause button CCMenuItem item1 = CCMenuItemFont.itemFromString("Pause", this, onPause); CCMenu menu = CCMenu.menuWithItems(item1); menu.position = new CCPoint(s.width / 2, s.height - 50); addChild(menu); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80)); layer1.IgnoreAnchorPointForPosition = false; layer1.Position = (new CCPoint(s.Width / 2, s.Height / 2)); layer1.ChildClippingMode = CCClipMode.Bounds; AddChild(layer1, 1); s = layer1.ContentSize; m_pInnerLayer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80)); m_pInnerLayer.IgnoreAnchorPointForPosition = false; m_pInnerLayer.Position = (new CCPoint(s.Width / 2, s.Height / 2)); m_pInnerLayer.ChildClippingMode = CCClipMode.Bounds; layer1.AddChild(m_pInnerLayer, 1); // // Add two labels using BM label class // CCLabelBMFont CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt"); label1.Position = new CCPoint(m_pInnerLayer.ContentSize.Width, m_pInnerLayer.ContentSize.Height * 0.75f); m_pInnerLayer.AddChild(label1); CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt"); label2.Position = new CCPoint(0, m_pInnerLayer.ContentSize.Height * 0.25f); m_pInnerLayer.AddChild(label2); CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 3.0f); CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 1.0f); m_pInnerLayer.RepeatForever(scaleTo2, scaleTo3); CCFiniteTimeAction seq = new CCRepeatForever( new CCSequence(scaleTo2, scaleTo3) ); m_pInnerLayer.RunAction(seq); CCSize size = Layer.VisibleBoundsWorldspace.Size; var move1 = new CCMoveTo(2, new CCPoint(size.Width / 2, size.Height)); var move2 = new CCMoveTo(2, new CCPoint(size.Width, size.Height / 2)); var move3 = new CCMoveTo(2, new CCPoint(size.Width / 2, 0)); var move4 = new CCMoveTo(2, new CCPoint(0, size.Height / 2)); layer1.RunAction(new CCRepeatForever(new CCSequence(move1, move2, move3, move4))); }
public SpriteColorOpacity() { CCSprite sprite1 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121)); CCSprite sprite2 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121)); CCSprite sprite3 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121)); CCSprite sprite4 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121)); CCSprite sprite5 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121)); CCSprite sprite6 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121)); CCSprite sprite7 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121)); CCSprite sprite8 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121)); CCSize s = CCDirector.sharedDirector().getWinSize(); sprite1.position = new CCPoint((s.width / 5) * 1, (s.height / 3) * 1); sprite2.position = new CCPoint((s.width / 5) * 2, (s.height / 3) * 1); sprite3.position = new CCPoint((s.width / 5) * 3, (s.height / 3) * 1); sprite4.position = new CCPoint((s.width / 5) * 4, (s.height / 3) * 1); sprite5.position = new CCPoint((s.width / 5) * 1, (s.height / 3) * 2); sprite6.position = new CCPoint((s.width / 5) * 2, (s.height / 3) * 2); sprite7.position = new CCPoint((s.width / 5) * 3, (s.height / 3) * 2); sprite8.position = new CCPoint((s.width / 5) * 4, (s.height / 3) * 2); CCActionInterval action = CCFadeIn.actionWithDuration(2); CCActionInterval action_back = (CCActionInterval)action.reverse(); CCAction fade = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action, action_back))); CCActionInterval tintred = CCTintBy.actionWithDuration(2, 0, -255, -255); CCActionInterval tintred_back = (CCActionInterval)tintred.reverse(); CCAction red = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintred, tintred_back))); CCActionInterval tintgreen = CCTintBy.actionWithDuration(2, -255, 0, -255); CCActionInterval tintgreen_back = (CCActionInterval)tintgreen.reverse(); CCAction green = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintgreen, tintgreen_back))); CCActionInterval tintblue = CCTintBy.actionWithDuration(2, -255, -255, 0); CCActionInterval tintblue_back = (CCActionInterval)tintblue.reverse(); CCAction blue = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintblue, tintblue_back))); sprite5.runAction(red); sprite6.runAction(green); sprite7.runAction(blue); sprite8.runAction(fade); // late add: test dirtyColor and dirtyPosition addChild(sprite1, 0, (int)kTagSprite.kTagSprite1); addChild(sprite2, 0, (int)kTagSprite.kTagSprite2); addChild(sprite3, 0, (int)kTagSprite.kTagSprite3); addChild(sprite4, 0, (int)kTagSprite.kTagSprite4); addChild(sprite5, 0, (int)kTagSprite.kTagSprite5); addChild(sprite6, 0, (int)kTagSprite.kTagSprite6); addChild(sprite7, 0, (int)kTagSprite.kTagSprite7); addChild(sprite8, 0, (int)kTagSprite.kTagSprite8); schedule(removeAndAddSprite, 2); }
public SpriteColorOpacity() { CCSprite sprite1 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121)); CCSprite sprite2 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121)); CCSprite sprite3 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121)); CCSprite sprite4 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121)); CCSprite sprite5 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121)); CCSprite sprite6 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121)); CCSprite sprite7 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121)); CCSprite sprite8 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121)); CCSize s = CCDirector.SharedDirector.WinSize; sprite1.Position = new CCPoint((s.Width / 5) * 1, (s.Height / 3) * 1); sprite2.Position = new CCPoint((s.Width / 5) * 2, (s.Height / 3) * 1); sprite3.Position = new CCPoint((s.Width / 5) * 3, (s.Height / 3) * 1); sprite4.Position = new CCPoint((s.Width / 5) * 4, (s.Height / 3) * 1); sprite5.Position = new CCPoint((s.Width / 5) * 1, (s.Height / 3) * 2); sprite6.Position = new CCPoint((s.Width / 5) * 2, (s.Height / 3) * 2); sprite7.Position = new CCPoint((s.Width / 5) * 3, (s.Height / 3) * 2); sprite8.Position = new CCPoint((s.Width / 5) * 4, (s.Height / 3) * 2); CCActionInterval action = new CCFadeIn(2); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCAction fade = new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(action, action_back))); CCActionInterval tintred = new CCTintBy(2, 0, -255, -255); CCActionInterval tintred_back = (CCActionInterval)tintred.Reverse(); CCAction red = new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(tintred, tintred_back))); CCActionInterval tintgreen = new CCTintBy(2, -255, 0, -255); CCActionInterval tintgreen_back = (CCActionInterval)tintgreen.Reverse(); CCAction green = new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(tintgreen, tintgreen_back))); CCActionInterval tintblue = new CCTintBy(2, -255, -255, 0); CCActionInterval tintblue_back = (CCActionInterval)tintblue.Reverse(); CCAction blue = new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(tintblue, tintblue_back))); sprite5.RunAction(red); sprite6.RunAction(green); sprite7.RunAction(blue); sprite8.RunAction(fade); // late add: test dirtyColor and dirtyPosition AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1); AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2); AddChild(sprite3, 0, (int)kTagSprite.kTagSprite3); AddChild(sprite4, 0, (int)kTagSprite.kTagSprite4); AddChild(sprite5, 0, (int)kTagSprite.kTagSprite5); AddChild(sprite6, 0, (int)kTagSprite.kTagSprite6); AddChild(sprite7, 0, (int)kTagSprite.kTagSprite7); AddChild(sprite8, 0, (int)kTagSprite.kTagSprite8); Schedule(removeAndAddSprite, 2); }
void StartPipes() { var create = new CCCallFunc(CreatePipesAndCoins); var wait = new CCDelayTime(3); var sequence = new CCSequence(create, wait); var repeartForever = new CCRepeatForever(sequence); this.RunAction(repeartForever); }
public Truck() { //[self setTextureRect:CGRectMake(0, 0, 308, 185)]; caster1 = new CCSprite(CCApplication.SharedApplication.SpriteFrameCache["Image 906 at frame 10.png"]); caster1.Position = new CCPoint(50, -38); caster2 = new CCSprite(CCApplication.SharedApplication.SpriteFrameCache["Image 906 at frame 10.png"]); caster2.Position = new CCPoint(-63, -38); CCSpriteFrame fc1 = CCApplication.SharedApplication.SpriteFrameCache["Image 904 at frame 10.png"]; CCSpriteFrame fc2 = CCApplication.SharedApplication.SpriteFrameCache["Image 904 at frame 10.png"]; CCSpriteFrame fc3 = CCApplication.SharedApplication.SpriteFrameCache["Image 904 at frame 10.png"]; var curtainanimation = new CCAnimation(new List<CCSpriteFrame>() { fc1, fc2, fc3 }, 0.2f); var curtainaction1 = new CCRepeatForever(new CCAnimate(curtainanimation)); var curtainaction2 = new CCRepeatForever(new CCAnimate(curtainanimation)); var curtainaction3 = new CCRepeatForever(new CCAnimate(curtainanimation)); curtain1 = new CCSprite(fc1); curtain2 = new CCSprite(fc1); curtain3 = new CCSprite(fc1); curtain1.Position = new CCPoint(-10, -5); curtain2.Position = new CCPoint(-40, -5); curtain3.Position = new CCPoint(-70, -5); head = new CCSprite(CCApplication.SharedApplication.SpriteFrameCache["Image 907 at frame 10.png"]); body = new CCSprite(CCApplication.SharedApplication.SpriteFrameCache["Image 915 at frame 10.png"]); body.Position = new CCPoint(-8, 5); door = new CCSprite(CCApplication.SharedApplication.SpriteFrameCache["Image 908 at frame 10.png"]); door.Position = new CCPoint(50, -5); light = new CCSprite(CCApplication.SharedApplication.SpriteFrameCache["Image 909 at frame 10.png"]); light.Position = new CCPoint(165, -30); AddChild(caster1); AddChild(caster2); AddChild(head); AddChild(curtain1); RunAction(curtainaction1); AddChild(curtain2); RunAction(curtainaction2); AddChild(curtain3); RunAction(curtainaction3); AddChild(body); AddChild(door); AddChild(light); }
public Layer1() : base(new ccColor4B (0, 255, 0, 255)) { CCMenuItemFont item1 = new CCMenuItemFont("Test pushScene", OnPushScene); CCMenuItemFont item2 = new CCMenuItemFont("Test pushScene w/transition", OnPushSceneTran); CCMenuItemFont item3 = new CCMenuItemFont("Quit", OnQuit); CCMenu menu = new CCMenu(item1, item2, item3); menu.AlignItemsVertically (); this.AddChild (menu); CGSize s = CCDirector.SharedDirector ().WinSize (); CCSprite sprite = new CCSprite("grossini.png", true); this.AddChild (sprite); sprite.Position = new CCPoint(s.Width-40, s.Height/2); var rotate = new CCRotateBy (2, 360); var repeat = new CCRepeatForever (rotate); sprite.RunAction (repeat); this.Schedule (new MonoMac.ObjCRuntime.Selector ("testDealloc:")); }