public CCParallel(params CCFiniteTimeAction[] actions) : base() { // Can't call base(duration) because max action duration needs to be determined here float maxDuration = 0.0f; foreach (CCFiniteTimeAction action in actions) { if (action.Duration > maxDuration) { maxDuration = action.Duration; } } Duration = maxDuration; Actions = actions; for (int i = 0; i < Actions.Length; i++) { var actionDuration = Actions [i].Duration; if (actionDuration < Duration) { Actions [i] = new CCSequence(Actions [i], new CCDelayTime(Duration - actionDuration)); } } }
public CCSequence(params CCFiniteTimeAction[] actions) : base() { Actions = new CCFiniteTimeAction[2]; var prev = actions [0]; // Can't call base(duration) because we need to calculate duration here float combinedDuration = 0.0f; foreach (CCFiniteTimeAction action in actions) { combinedDuration += action.Duration; } Duration = combinedDuration; if (actions.Length == 1) { InitCCSequence(prev, new CCExtraAction()); } else { // Basically what we are doing here is creating a whole bunch of // nested CCSequences from the actions. for (int i = 1; i < actions.Length - 1; i++) { prev = new CCSequence(prev, actions [i]); } InitCCSequence(prev, actions [actions.Length - 1]); } }
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 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(); 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 override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(255, 255, 0, 80)); layer1.Position = (new CCPoint(s.Width / 3, s.Height / 2)); layer1.IgnoreAnchorPointForPosition = false; AddChild(layer1, 1); var layer2 = new CCLayerColor(new CCColor4B(0, 0, 255, 255)); layer2.Position = (new CCPoint((s.Width / 3) * 2, s.Height / 2)); layer2.IgnoreAnchorPointForPosition = false; AddChild(layer2, 1); var actionTint = new CCTintBy (2, -255, -127, 0); var actionTintBack = actionTint.Reverse(); var seq1 = new CCSequence(actionTint, actionTintBack); layer1.RunAction(seq1); var actionFade = new CCFadeOut(2.0f); var actionFadeBack = actionFade.Reverse(); var seq2 = new CCSequence(actionFade, actionFadeBack); layer2.RunAction(seq2); }
public void FadeThenRemove(float delta) { var seq = new CCSequence( new CCFadeTo(1.0f, 0), new CCCallFunc(RemoveSpriteAndBody)); sprite.RunAction(seq); }
public override void OnEnter() { base.OnEnter(); var effect = new CCSequence(new CCDelayTime (2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false)); // cleanup RemoveChild(bgNode, true); // background var layer = new CCLayerColor(new CCColor4B(255, 0, 0, 255)); AddChild(layer, -10); var sprite = new CCSprite("Images/grossini"); sprite.Position = new CCPoint(50, 80); layer.AddChild(sprite, 10); // foreground var layer2Node = new CCNode (); var layer2 = new CCLayerColor(new CCColor4B(0, 255, 0, 255)); var fog = new CCSprite("Images/Fog"); var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA}; fog.BlendFunc = bf; layer2.AddChild(fog, 1); AddChild(layer2Node, 1); layer2Node.AddChild (layer2); layer2Node.RepeatForever(effect); }
public CCSequence (params CCFiniteTimeAction[] actions) : base () { Actions = new CCFiniteTimeAction[2]; var prev = actions [0]; // Can't call base(duration) because we need to calculate duration here float combinedDuration = 0.0f; foreach (CCFiniteTimeAction action in actions) { combinedDuration += action.Duration; } Duration = combinedDuration; if (actions.Length == 1) { InitCCSequence (prev, new CCExtraAction ()); } else { // Basically what we are doing here is creating a whole bunch of // nested CCSequences from the actions. for (int i = 1; i < actions.Length - 1; i++) { prev = new CCSequence (prev, actions [i]); } InitCCSequence (prev, actions [actions.Length - 1]); } }
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(); CCSize winSize = VisibleBoundsWorldspace.Size; float x = winSize.Center.X; float y = winSize.Center.Y; //var widgetSize = _widget->getContentSize(); var moveTo = new CCMoveBy(1.0f, new CCPoint(30, 0)); var moveBack = moveTo.Reverse(); var rotateBy = new CCRotateBy(1.0f, 180); var scaleBy = new CCScaleTo(1.0f, -2.0f); var action = new CCSequence(moveTo, moveBack, rotateBy, scaleBy); var normalSprite1 = new CCSprite("Images/animationbuttonnormal.png"); normalSprite1.Position = winSize.Center; normalSprite1.PositionX -= 100; normalSprite1.PositionY += 100; normalSprite1.FlipY = true; AddChild(normalSprite1); normalSprite1.RunAction(action); var normalSprite2 = new CCScale9Sprite("Images/animationbuttonnormal.png"); normalSprite2.Position = winSize.Center; normalSprite2.PositionX -= 80; normalSprite2.PositionY += 100; normalSprite2.IsScale9Enabled = false; normalSprite2.Opacity = 100; AddChild(normalSprite2); normalSprite2.Color = CCColor3B.Green; normalSprite2.RunAction(action); var sp1 = new CCScale9Sprite("Images/animationbuttonnormal.png"); sp1.Position = winSize.Center; sp1.PositionX -= 100; sp1.PositionY -= 50; sp1.Scale = 1.2f; sp1.ContentSize = new CCSize(100, 100); sp1.Color = CCColor3B.Green; AddChild(sp1); sp1.RunAction(action); var sp2 = new CCScale9Sprite("Images/animationbuttonnormal.png"); sp2.Position = winSize.Center; sp2.PositionX += 100; sp2.PositionY -= 50; sp2.PreferredSize = sp1.ContentSize * 1.2f; sp2.ContentSize = new CCSize(100, 100); sp2.Color = CCColor3B.Green; AddChild(sp2); sp2.RunAction(action); }
public override void OnEnter() { base.OnEnter(); var move = new CCActionEase(new CCMoveBy(1, new CCPoint(0, 20))); var moveSeq = new CCSequence(move, move.Reverse()); AddAction(new CCRepeatForever(moveSeq)); }
public CCSequenceState(CCSequence action, CCNode target) : base(action, target) { actionSequences = action.Actions; hasInfiniteAction = (actionSequences [0] is CCRepeatForever) || (actionSequences [1] is CCRepeatForever); split = actionSequences [0].Duration / Duration; last = -1; }
public void disableMenuCallback(object pSender) { menu1.Enabled = false; var wait = new CCDelayTime (5); var enable = new CCCallFunc(enableMenuCallback); var seq = new CCSequence(wait, enable); menu1.RunAction(seq); }
public CCSequenceState (CCSequence action, CCNode target) : base (action, target) { actionSequences = action.Actions; hasInfiniteAction = (actionSequences [0] is CCRepeatForever) || (actionSequences [1] is CCRepeatForever); split = actionSequences [0].Duration / Duration; last = -1; }
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 void disableMenuCallback(object pSender) { m_pMenu1.Enabled = false; CCDelayTime wait = new CCDelayTime (5); CCCallFunc enable = new CCCallFunc(enableMenuCallback); CCFiniteTimeAction seq = new CCSequence(wait, enable); m_pMenu1.RunAction(seq); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; var progressTo = new CCProgressTo(6, 100); var tint = new CCSequence(new CCTintTo (1, 255, 0, 0), new CCTintTo (1, 0, 255, 0), new CCTintTo (1, 0, 0, 255)); var fade = new CCSequence(new CCFadeTo (1.0f, 0), new CCFadeTo (1.0f, 255)); CCProgressTimer left = new CCProgressTimer(new CCSprite(s_pPathSister1)); left.Type = CCProgressTimerType.Bar; // Setup for a bar starting from the bottom since the midpoint is 0 for the y left.Midpoint = new CCPoint(0.5f, 0.5f); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change left.BarChangeRate = new CCPoint(1, 0); AddChild(left); left.Position = new CCPoint(100, s.Height / 2); left.RepeatForever(progressTo); left.RepeatForever(tint); left.AddChild(new CCLabelTtf("Tint", "arial", 20.0f)); CCProgressTimer middle = new CCProgressTimer(new CCSprite(s_pPathSister2)); middle.Type = CCProgressTimerType.Bar; // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle.Midpoint = new CCPoint(0.5f, 0.5f); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change middle.BarChangeRate = new CCPoint(1, 1); AddChild(middle); middle.Position = new CCPoint(s.Width / 2, s.Height / 2); middle.RepeatForever(progressTo); middle.RepeatForever(fade); middle.AddChild(new CCLabelTtf("Fade", "arial", 20.0f)); CCProgressTimer right = new CCProgressTimer(new CCSprite(s_pPathSister2)); right.Type = CCProgressTimerType.Bar; // Setup for a bar starting from the bottom since the midpoint is 0 for the y right.Midpoint = new CCPoint(0.5f, 0.5f); // Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change right.BarChangeRate = new CCPoint(0, 1); AddChild(right); right.Position = new CCPoint(s.Width - 100, s.Height / 2); right.RepeatForever(progressTo); right.RepeatForever(tint); right.RepeatForever(fade); right.AddChild(new CCLabelTtf("Tint and Fade", "arial", 20.0f)); }
public SpriteAliased() { sprite1 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121)); AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1); sprite2 = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121)); AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2); var scale = new CCScaleBy(2, 5); var scale_back = scale.Reverse(); seq = new CCSequence(scale, scale_back); }
public virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen) { // if insert enter, treat as default to detach with ime if ("\n" == text) { return(false); } // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore. if (pSender.Text.Length >= m_nCharLimit) { return(true); } // create a insert text sprite and do some action CCLabelTtf label = new CCLabelTtf(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE); this.AddChild(label); CCColor3B color = new CCColor3B { R = 226, G = 121, B = 7 }; label.Color = color; // move the sprite from top to position CCPoint endPos = pSender.Position; if (pSender.Text.Length > 0) { endPos.X += pSender.ContentSize.Width / 2; } CCSize inputTextSize = label.ContentSize; CCPoint beginPos = new CCPoint(endPos.X, Layer.VisibleBoundsWorldspace.Size.Height - inputTextSize.Height * 2); float duration = 0.5f; label.Position = beginPos; label.Scale = 8; CCAction seq = new CCSequence( new CCSpawn( new CCMoveTo(duration, endPos), new CCScaleTo(duration, 1), new CCFadeOut(duration)), new CCCallFuncN(callbackRemoveNodeWhenDidAction)); label.RunAction(seq); return(false); }
public Atlas4() { m_time = 0; // Upper Label label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); AddChild(label); label.AnchorPoint = CCPoint.AnchorMiddle; var BChar = (CCSprite)label[0]; var FChar = (CCSprite)label[7]; var AChar = (CCSprite)label[12]; var rotate = new CCRotateBy (2, 360); var rot_4ever = new CCRepeatForever (rotate); var scale = new CCScaleBy(2, 1.5f); var scale_back = scale.Reverse(); var scale_seq = new CCSequence(scale, scale_back); var scale_4ever = new CCRepeatForever (scale_seq); var jump = new CCJumpBy (0.5f, new CCPoint(), 60, 1); var jump_4ever = new CCRepeatForever (jump); var fade_out = new CCFadeOut (1); var fade_in = new CCFadeIn (1); var seq = new CCSequence(fade_out, fade_in); var fade_4ever = new CCRepeatForever (seq); BChar.RunAction(rot_4ever); BChar.RunAction(scale_4ever); FChar.RunAction(jump_4ever); AChar.RunAction(fade_4ever); // Bottom Label label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt"); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); var lastChar = (CCSprite)label2[3]; lastChar.RunAction(rot_4ever); //schedule( schedule_selector(Atlas4::step), 0.1f); base.Schedule(step, 0.1f); }
public SpriteOffsetAnchorFlip() { CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFrames("animations/grossini.plist"); cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray"); var animFrames = new List<CCSpriteFrame>(); string tmp = ""; for (int j = 0; j < 14; j++) { string temp = ""; if (j +1< 10) { temp = "0" + (j + 1); } else { temp = (j + 1).ToString(); } tmp = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = cache[tmp]; animFrames.Add(frame); } animation = new CCAnimation(animFrames, 0.3f); var flip = new CCFlipY(true); var flip_back = flip.Reverse(); var delay = new CCDelayTime (1); seq = new CCSequence(delay, flip, delay, flip_back); sprites = new CCSprite[numOfSprites]; pointSprites = new CCSprite[numOfSprites]; for(int i = 0; i < numOfSprites; i++) { // Animation using Sprite batch sprites[i] = new CCSprite("grossini_dance_01.png"); AddChild(sprites[i], 0); pointSprites[i] = new CCSprite("Images/r1"); AddChild(pointSprites[i], 1); } }
private void RunAction(CCNode node, CCBSequenceProperty pSeqProp, float fTweenDuration) { List <CCBKeyframe> keyframes = pSeqProp.Keyframes; int numKeyframes = keyframes.Count; if (numKeyframes > 1) { // Make an animation! var actions = new List <CCFiniteTimeAction>(); CCBKeyframe keyframeFirst = keyframes[0]; float timeFirst = keyframeFirst.Time + fTweenDuration; if (timeFirst > 0) { actions.Add(new CCDelayTime(timeFirst)); } for (int i = 0; i < numKeyframes - 1; ++i) { CCBKeyframe kf0 = keyframes[i]; CCBKeyframe kf1 = keyframes[i + 1]; CCFiniteTimeAction action = GetAction(kf0, kf1, pSeqProp.Name, node); if (action != null) { // Apply easing action = GetEaseAction(action, kf0.EasingType, kf0.EasingOpt); actions.Add(action); } } if (actions.Count > 1) { CCFiniteTimeAction seq = new CCSequence(actions.ToArray()); node.RunAction(seq); } else { node.RunAction(actions[0]); } } }
private void InitCCSpawn (CCFiniteTimeAction action1, CCFiniteTimeAction action2) { Debug.Assert (action1 != null); Debug.Assert (action2 != null); float d1 = action1.Duration; float d2 = action2.Duration; ActionOne = action1; ActionTwo = action2; if (d1 > d2) { ActionTwo = new CCSequence (action2, new CCDelayTime (d1 - d2)); } else if (d1 < d2) { ActionOne = new CCSequence (action1, new CCDelayTime (d2 - d1)); } }
private void InitCCSpawn(CCFiniteTimeAction action1, CCFiniteTimeAction action2) { Debug.Assert(action1 != null); Debug.Assert(action2 != null); float d1 = action1.Duration; float d2 = action2.Duration; ActionOne = action1; ActionTwo = action2; if (d1 > d2) { ActionTwo = new CCSequence(action2, new CCDelayTime(d1 - d2)); } else if (d1 < d2) { ActionOne = new CCSequence(action1, new CCDelayTime(d2 - d1)); } }
public override void OnEnter() { base.OnEnter(); var effect = new CCSequence(new CCDelayTime (2.0f), new CCShaky3D(5.0f, new CCGridSize(5, 5), 16, false)); // cleanup contentLayer.RemoveChild(bgNode, true); // background var layer = new CCDrawNode(); layer.Color = CCColor3B.Red; layer.Opacity = 255; layer.DrawRect(VisibleBoundsWorldspace); AddChild(layer, -10); var sprite = new CCSprite("Images/grossini"); sprite.Position = new CCPoint(50, 80); layer.AddChild(sprite, 10); // foreground var layer2BaseGrid = new CCNodeGrid (); var layer2 = new CCDrawNode(); layer2.Color = CCColor3B.Green; layer2.Opacity = 255; layer2.DrawRect(VisibleBoundsWorldspace); var fog = new CCSprite("Images/Fog"); var bf = new CCBlendFunc {Source = CCOGLES.GL_SRC_ALPHA, Destination = CCOGLES.GL_ONE_MINUS_SRC_ALPHA}; fog.BlendFunc = bf; layer2.AddChild(fog, 1); AddChild(layer2BaseGrid, 1); layer2BaseGrid.AddChild (layer2); layer2BaseGrid.RepeatForever(effect); }
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; CCFiniteTimeAction fade = new CCFadeOut (1.0f); CCFiniteTimeAction fade_in = fade.Reverse(); CCFiniteTimeAction seq = new CCSequence(fade, fade_in); CCAction repeat = new CCRepeatForever ((CCFiniteTimeAction)seq); label2.RunAction(repeat); m_time = 0; Schedule(step); //:@selector(step:)]; }
public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen) { // create a delete text sprite and do some action CCLabelTtf label = new CCLabelTtf(delText, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE); this.AddChild(label); // move the sprite to fly out CCPoint beginPos = pSender.Position; CCSize textfieldSize = pSender.ContentSize; CCSize labelSize = label.ContentSize; beginPos.X += (textfieldSize.Width - labelSize.Width) / 2.0f; int RAND_MAX = 32767; CCRandom rand = new CCRandom(); CCSize winSize = Layer.VisibleBoundsWorldspace.Size; CCPoint endPos = new CCPoint(-winSize.Width / 4.0f, winSize.Height * (0.5f + (float)CCRandom.Next() / (2.0f * RAND_MAX))); float duration = 1; float rotateDuration = 0.2f; int repeatTime = 5; label.Position = beginPos; CCAction seq = new CCSequence( new CCSpawn( new CCMoveTo(duration, endPos), new CCRepeat( new CCRotateBy(rotateDuration, (CCRandom.Next() % 2 > 0) ? 360 : -360), (uint)repeatTime), new CCFadeOut(duration)), new CCCallFuncN(callbackRemoveNodeWhenDidAction)); label.RunAction(seq); return(false); }
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)); }
public CCParallel (params CCFiniteTimeAction[] actions) : base () { // Can't call base(duration) because max action duration needs to be determined here float maxDuration = 0.0f; foreach (CCFiniteTimeAction action in actions) { if (action.Duration > maxDuration) { maxDuration = action.Duration; } } Duration = maxDuration; Actions = actions; for (int i = 0; i < Actions.Length; i++) { var actionDuration = Actions [i].Duration; if (actionDuration < Duration) { Actions [i] = new CCSequence (Actions [i], new CCDelayTime (Duration - actionDuration)); } } }
void ShowPointsWithImagesForValue(int pointValue, CCPoint positionToShowScore) { CCSprite scoreLabel; if (pointValue == 100) { scoreLabel = new CCSprite("100points"); } else if (pointValue == 500) { scoreLabel = new CCSprite("500points"); } else if (pointValue == 1000) { scoreLabel = new CCSprite("1000points"); } else if (pointValue == 5000) { scoreLabel = new CCSprite("5000points"); } else if (pointValue == 10000) { scoreLabel = new CCSprite("10000points"); } else { //default scoreLabel = new CCSprite("100points"); } AddChild(scoreLabel, Constants.DepthPointScore); scoreLabel.Position = positionToShowScore; CCMoveTo moveAction = new CCMoveTo(1.0f, new CCPoint(scoreLabel.Position.X, scoreLabel.Position.Y + 25)); scoreLabel.RunAction(moveAction); CCSequence seq = new CCSequence( new CCFadeTo(1.5f, 20), new CCCallFuncN(RemoveThisChild)); scoreLabel.RunAction(seq); }
public override void OnEnter() { base.OnEnter(); CCSize s = tileLayersContainer.ContentSize; CCTileMapLayer layer = tileMap.LayerNamed("Trees"); CCMoveBy move = new CCMoveBy (5, new CCPoint(500, 550)); CCMoveBy move2 = new CCMoveBy (5, new CCPoint(250, 250)); CCFiniteTimeAction back = move.Reverse(); CCSequence seq = new CCSequence(move, back); tileMap.Camera.NearAndFarOrthographicZClipping = new CCNearAndFarClipping(-2000f, 2000f); layer.RunAction(seq); tileLayersContainer.RunAction(new CCSequence(move2.Reverse(), move2)); }
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)); }
protected override void Step(float dt) { base.Step(dt); if (gameSuspended) return; var batchnode = GetChildByTag((int)Tags.SpriteManager) as CCSpriteBatchNode; var bird = batchnode.GetChildByTag((int)Tags.Bird) as CCSprite; var particles = GetChildByTag((int)Tags.Particles) as CCParticleSystem; bird_pos.X += bird_vel.X * dt; if (bird_vel.X < -30.0f && birdLookingRight) { birdLookingRight = false; bird.ScaleX = -1.0f; } else if (bird_vel.X > 30.0f && !birdLookingRight) { birdLookingRight = true; bird.ScaleX = 1.0f; } var bird_size = bird.ContentSize; float max_x = 320 - bird_size.Width / 2; float min_x = 0 + bird_size.Width / 2; if (bird_pos.X > max_x) bird_pos.X = max_x; if (bird_pos.X < min_x) bird_pos.X = min_x; bird_vel.Y += bird_acc.Y * dt; bird_pos.Y += bird_vel.Y * dt; var bonus = batchnode.GetChildByTag((int)Tags.BomusStart + currentBonusType); if (bonus.Visible) { var bonus_pos = bonus.Position; float range = 20.0f; if (bird_pos.X > bonus_pos.X - range && bird_pos.X < bonus_pos.Y + range && bird_pos.Y > bonus_pos.Y - range && bird_pos.Y < bonus_pos.Y + range) { switch (currentBonusType) { case (int)Bonus.Bonus5: score += 5000; break; case (int)Bonus.Bonus10: score += 10000; break; case (int)Bonus.Bonus50: score += 50000; break; case (int)Bonus.Bonus100: score += 100000; break; } var scorelabel = GetChildByTag((int)Tags.ScoreLabel) as CCLabelBMFont; scorelabel.Text = score.ToString(); var a1 = new CCScaleTo(.2f, 1.5f, .08f); var a2 = new CCScaleTo(.2f, 1f, 1f); var a3 = new CCSequence(a1, a2, a1, a2, a1, a2); scorelabel.RunAction(a3); ResetBonus(); } } int t; if (bird_vel.Y < 0) { t = (int)Tags.PlatformsStart; for (t = (int)Tags.PlatformsStart; t < (int)Tags.PlatformsStart + numPlatforms; t++) { var platform = batchnode.GetChildByTag(t) as CCSprite; var platform_size = platform.ContentSize; var platform_pos = platform.Position; max_x = platform_pos.X - platform_size.Width / 2 - 10; min_x = platform_pos.X + platform_size.Width / 2 + 10; float min_y = platform_pos.Y + (platform_size.Height + bird_size.Height) / 2 - platformTopPadding; if (bird_pos.X > max_x && bird_pos.X < min_x && bird_pos.Y > platform_pos.Y && bird_pos.Y < min_y) { Jump(); } } if (bird_pos.Y < -bird_size.Height / 2) { ShowHighScores(); } } else if (bird_pos.Y > 240) { float delta = bird_pos.Y - 240; bird_pos.Y = 240; currentPlatformY -= delta; for (t = (int)Tags.CloudsStart; t < (int)Tags.CloudsStart + numClouds; t++) { var cloud = batchnode.GetChildByTag(t) as CCSprite; var pos = cloud.Position; pos.Y -= delta * cloud.ScaleY * 0.8f; if (pos.Y < -cloud.ContentSize.Height / 2) { currentCloudTag = t; ResetCloud(); } else { cloud.Position = pos; } } for (t = (int)Tags.PlatformsStart; t < (int)Tags.PlatformsStart + numPlatforms; t++) { var platform = batchnode.GetChildByTag(t) as CCSprite; var pos = platform.Position; pos = new CCPoint(pos.X, pos.Y - delta); if (pos.Y < -platform.ContentSize.Height / 2) { currentPlatformTag = t; ResetPlatform(); } else { platform.Position = pos; } } if (bonus.Visible) { var pos = bonus.Position; pos.Y -= delta; if (pos.Y < -bonus.ContentSize.Height / 2) { ResetBonus(); //[self resetBonus]; } else { bonus.Position = pos; } } score += (int)delta; var scoreLabel = GetChildByTag((int)Tags.ScoreLabel) as CCLabelBMFont; scoreLabel.Text = score.ToString(); } bird.Position = bird_pos; if (particles != null) { var particle_pos = new CCPoint(bird_pos.X, bird_pos.Y - 17); particles.Position = particle_pos; } }
public override void OnEnter() { base.OnEnter(); CCSize s = tileLayersContainer.ContentSize; tileLayersContainer.Position = new CCPoint(-s.Width / 2, 0); CCMoveBy move = new CCMoveBy (10, new CCPoint(300, 250)); CCFiniteTimeAction back = move.Reverse(); CCSequence seq = new CCSequence(move, back); m_tamara.RunAction(new CCRepeatForever (seq)); Schedule(repositionSprite); tileMap.Camera.NearAndFarOrthographicZClipping = new CCNearAndFarClipping(-2000f, 2000f); Window.IsUseDepthTesting = true; }
void ShowPointsWithFontLabelForValue(int pointValue, CCPoint positionToShowScore) { CCLabelTtf scoreLabel = new CCLabelTtf(string.Format("{0}", pointValue), "MarkerFelt", 22); AddChild(scoreLabel, Constants.DepthPointScore); scoreLabel.Color = new CCColor3B(255, 255, 255); scoreLabel.Position = positionToShowScore; CCMoveTo moveAction = new CCMoveTo(1.0f, new CCPoint(scoreLabel.Position.X, scoreLabel.Position.Y + 25)); scoreLabel.RunAction(moveAction); CCSequence seq = new CCSequence( new CCFadeTo(1.5f, 20), new CCCallFuncN(RemoveThisLabel)); scoreLabel.RunAction(seq); }
internal void ShowBoardMessage(string theMessage) { CCLabelTtf boardMessage = new CCLabelTtf(theMessage, "MarkerFelt", 22); AddChild(boardMessage, Constants.DepthPointScore); boardMessage.Color = new CCColor3B(255, 255, 255); boardMessage.PositionX = screenWidth / 2; boardMessage.PositionY = screenHeight * .7f; CCSequence seq = new CCSequence( new CCScaleTo(2.0f, 2.0f), new CCFadeTo(1.0f, 0), new CCCallFuncN(RemoveBoardMessage) //NOTE: CCCallFuncN works, CCCallFunc does not. ); boardMessage.RunAction(seq); }
public void RunAnimationsForSequenceIdTweenDuration(int nSeqId, float fTweenDuration) { Debug.Assert(nSeqId != -1, "Sequence id couldn't be found"); _rootNode.StopAllActions(); foreach (var pElement in _nodeSequences) { CCNode node = pElement.Key; node.StopAllActions(); // Refer to CCBReader::readKeyframe() for the real type of value Dictionary <int, Dictionary <string, CCBSequenceProperty> > seqs = pElement.Value; var seqNodePropNames = new List <string>(); Dictionary <string, CCBSequenceProperty> seqNodeProps; if (seqs.TryGetValue(nSeqId, out seqNodeProps)) { // Reset nodes that have sequence node properties, and run actions on them foreach (var pElement1 in seqNodeProps) { string propName = pElement1.Key; CCBSequenceProperty seqProp = pElement1.Value; seqNodePropNames.Add(propName); SetFirstFrame(node, seqProp, fTweenDuration); RunAction(node, seqProp, fTweenDuration); } } // Reset the nodes that may have been changed by other timelines Dictionary <string, object> nodeBaseValues; if (_baseValues.TryGetValue(node, out nodeBaseValues)) { foreach (var pElement2 in nodeBaseValues) { if (!seqNodePropNames.Contains(pElement2.Key)) { object value = pElement2.Value; if (value != null) { SetAnimatedProperty(pElement2.Key, node, value, fTweenDuration); } } } } } // Make callback at end of sequence CCBSequence seq = GetSequence(nSeqId); CCAction completeAction = new CCSequence( new CCDelayTime(seq.Duration + fTweenDuration), new CCCallFunc(SequenceCompleted) ); _rootNode.RunAction(completeAction); // Set the running scene if (seq.CallBackChannel != null) { CCAction action = (CCAction)ActionForCallbackChannel(seq.CallBackChannel); if (action != null) { _rootNode.RunAction(action); } } if (seq.SoundChannel != null) { CCAction action = (CCAction)ActionForSoundChannel(seq.SoundChannel); if (action != null) { _rootNode.RunAction(action); } } _runningSequence = GetSequence(nSeqId); }