private void performanceActions20(CCSprite pSprite) { CCSize size = CCDirector.SharedDirector.WinSize; if (Random.Float_0_1() < 0.2f) { pSprite.Position = new CCPoint((Random.Next() % (int)size.Width), (Random.Next() % (int)size.Height)); } else { pSprite.Position = new CCPoint(-1000, -1000); } float period = 0.5f + (Random.Next() % 1000) / 500.0f; CCRotateBy rot = new CCRotateBy(period, 360.0f * Random.Float_0_1()); var rot_back = (CCActionInterval)rot.Reverse(); CCAction permanentRotation = new CCRepeatForever(CCSequence.FromActions(rot, rot_back)); pSprite.RunAction(permanentRotation); float growDuration = 0.5f + (Random.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 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 = CCSequence.FromActions(fade, fade_in); CCAction repeat = new CCRepeatForever((CCActionInterval)seq); label2.RunAction(repeat); m_time = 0; Schedule(step); //:@selector(step:)]; }
public override bool Init() { if (base.Init()) { CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor background = new CCLayerColor(new CCColor4B(255, 0, 255, 255)); AddChild(background); CCLayerColor sprite_a = new CCLayerColor(new CCColor4B(255, 0, 0, 255), 700, 700); sprite_a.AnchorPoint = new CCPoint(0.5f, 0.5f); sprite_a.IgnoreAnchorPointForPosition = true; sprite_a.Position = new CCPoint(0.0f, s.Height / 2); AddChild(sprite_a); sprite_a.RunAction(new CCRepeatForever((CCActionInterval)CCSequence.FromActions( new CCMoveTo(1.0f, new CCPoint(1024.0f, 384.0f)), new CCMoveTo(1.0f, new CCPoint(0.0f, 384.0f))))); CCLayerColor sprite_b = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 400, 400); sprite_b.AnchorPoint = new CCPoint(0.5f, 0.5f); sprite_b.IgnoreAnchorPointForPosition = true; sprite_b.Position = new CCPoint(s.Width / 2, s.Height / 2); AddChild(sprite_b); CCMenuItemLabel label = new CCMenuItemLabel(new CCLabelTTF("Flip Me", "Helvetica", 24), callBack); CCMenu menu = new CCMenu(label); menu.Position = new CCPoint(s.Width - 200.0f, 50.0f); AddChild(menu); return(true); } return(false); }
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 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 = (new CCPoint(100, 160)); sp2.position = (new CCPoint(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 override void OnEnter() { base.OnEnter(); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCSprite bg = new CCSprite("Images/background3"); AddChild(bg, 0, EffectAdvanceScene.kTagBackground); bg.Position = new CCPoint(x / 2, y / 2); grossini = new CCSprite("Images/grossinis_sister2"); bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1); grossini.Position = new CCPoint(x / 3.0f, 200); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(sc, sc_back)))); tamara = new CCSprite("Images/grossinis_sister1"); bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2); tamara.Position = new CCPoint(2 * x / 3.0f, 200); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(title(), "arial", 28); label.Position = new CCPoint(x / 2, y - 80); AddChild(label); label.Tag = EffectAdvanceScene.kTagLabel; string strSubtitle = subtitle(); if (strSubtitle != null) { CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16); AddChild(l, 101); l.Position = new CCPoint(size.Width / 2, size.Height - 80); } CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback); CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback); CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(size.Width / 2 - 100, 30); item2.Position = new CCPoint(size.Width / 2, 30); item3.Position = new CCPoint(size.Width / 2 + 100, 30); AddChild(menu, 1); }
private void DisplayHint() { _isDisplayingHint = true; var idx = FindMove(); var x = idx % Constants.KBoardWidth; var y = (int)Math.Floor((double)idx / Constants.KBoardWidth); var connected = FindConnectedGems(x, y); for (var i = 0; i < connected.Count; i++) { idx = connected[i]; x = idx % Constants.KBoardWidth; y = (int)Math.Floor((double)idx / Constants.KBoardWidth); var actionFadeIn = new CCFadeIn(0.5f); var actionFadeOut = new CCFadeOut(0.5f); var actionSeq = new CCSequence(actionFadeIn, actionFadeOut); var action = new CCRepeatForever(actionSeq); var hintSprite = new CCSprite("crystalscrystals/hint.png"); hintSprite.Opacity = 0; hintSprite.Position = new CCPoint(_fieldPositionZero.X + x * Constants.KGemSize, _fieldPositionZero.Y + y * Constants.KGemSize); hintSprite.AnchorPoint = CCPoint.Zero; _hintLayer.AddChild(hintSprite); hintSprite.RunAction(action); } }
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 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); }
/// <summary> /// /// </summary> /// <param name="friends">周边相同的猫的集合</param> internal void RemoveCat(List <GameObject> friends) { // int score=Control.Instance.ScoreWithStartNumber(friends.Count); //GameLayer.Instance.AddScore(score); TouchLayer.isTouch = false; List <int> columnList = new List <int>();//存储被消掉的列 foreach (GameObject item in friends) { catsList.Remove(item); Point key = item.GetComponent <Cat>().point; catsDic[key] = null; CatManager.Instance.RemoveCat(item); columnList.Add(key.X); } float maxTime = 0; foreach (int column in columnList) { float t = RepairRaw(column);//找到每一空余的列,调整行; if (maxTime < t) { maxTime = t; } } //要等到行的操作完成后,才进行列的操作 this.transform.RunAction(CCSequence.Create(CCDelay.Create(maxTime), CCCallFunc.Create(RepairColumn))); }
private void RunOutroAnimations() { var slideOutHeader = new CCMoveTo(1, new CCPoint(0, 200)); var sequence = new CCSequence(slideOutHeader, new CCDelayTime(0.2f), new CCCallFunc(() => CCDirector.SharedDirector.ReplaceScene(new MainScene()))); _gameHeader.RunAction(sequence); }
public SpriteBatchNodeAliased() { CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 10); addChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSize s = CCDirector.sharedDirector().getWinSize(); CCSprite sprite1 = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121)); sprite1.position = (new CCPoint(s.width / 2 - 100, s.height / 2)); batch.addChild(sprite1, 0, (int)kTagSprite.kTagSprite1); CCSprite sprite2 = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121)); sprite2.position = (new CCPoint(s.width / 2 + 100, s.height / 2)); batch.addChild(sprite2, 0, (int)kTagSprite.kTagSprite2); CCActionInterval scale = CCScaleBy.actionWithDuration(2, 5); CCActionInterval scale_back = (CCActionInterval)scale.reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.actions(scale, scale_back)); CCAction repeat = CCRepeatForever.actionWithAction(seq); CCAction repeat2 = (CCAction)(repeat.copy()); sprite1.runAction(repeat); sprite2.runAction(repeat2); }
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 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 Setup() { const int depth = 9; CCNode parent = this; for (int i = 0; i < depth; i++) { int size = 225 - i * (225 / (depth * 2)); CCClippingNode clipper = new CCClippingNode(); clipper.ContentSize = new CCSize(size, size); clipper.AnchorPoint = new CCPoint(0.5f, 0.5f); clipper.Position = new CCPoint(parent.ContentSize.Width / 2, parent.ContentSize.Height / 2); clipper.AlphaThreshold = 0.05f; clipper.RunAction(new CCRepeatForever(new CCRotateBy(i % 3 != 0 ? 1.33f : 1.66f, i % 2 != 0 ? 90 : -90))); parent.AddChild(clipper); CCNode stencil = new CCSprite(TestResource.s_pPathGrossini); stencil.Scale = 2.5f - (i * (2.5f / depth)); stencil.AnchorPoint = new CCPoint(0.5f, 0.5f); stencil.Position = new CCPoint(clipper.ContentSize.Width / 2, clipper.ContentSize.Height / 2); stencil.Visible = false; stencil.RunAction(CCSequence.FromActions(new CCDelayTime(i), new CCShow())); clipper.Stencil = stencil; clipper.AddChild(stencil); parent = clipper; } }
/********************************************************************** *********************************************************************/ //Receiver sends ACK public static void SendACKFor(int seqnum) { if (!stopEverything) { //define object float yPos = 15 + (65 * (28 - seqnum)); //where the box !starts! OldPipelineProtocolsACK pp; //smaller rectangle at -- switch (seqnum) { case -1: pp = new OldPipelineProtocolsACK(seqnum, 5, 1); yPos = yPos + 12; //since it's smaller, it has to be a little further up, in order to look pretty break; default: pp = new OldPipelineProtocolsACK(seqnum, 0); break; } pp.Position = new CCPoint(280, yPos); layer.AddChild(pp); //define action float timeToTake = 5f; var distance = new CCPoint(80, yPos); //82 to 278 = 278-82 = 196 var sendPackageAction = new CCMoveTo(timeToTake, distance); //this action moves the object 196 in x-direction within 5 seconds var removeAction = new CCRemoveSelf(); //this action removes the object*/ //define sequence of actions and apply to object var cc_seq1 = new CCSequence(sendPackageAction, removeAction); pp.RunAction(cc_seq1); } }
/********************************************************************** *********************************************************************/ //this method imitates the sender of a packet. It is called by the method invoke public static void SendPackageAt(int seqnum) { if (!stopEverything) { if (seqnum == nextSeqnum) { DrawFillLeft(seqnum); } //pending if not already acknowledged . Add to list only once if (!arrivedAck.Any() && !pendingAck.Contains(seqnum) || arrivedAck.Any() && !arrivedAck.Contains(seqnum) && !pendingAck.Contains(seqnum)) { pendingAck.Add(seqnum); } //define object float yPos = 15 + (65 * (28 - seqnum)); //calculate where the box !starts! in the coordinate system var pp = new OldPipelineProtocolsPack(seqnum, 0); pp.Position = new CCPoint(80, yPos); layer.AddChild(pp); //define actions float timeToTake = 5f; var distance = new CCPoint(280, yPos); //82 to 278 = 278-82 = 196 var sendPackageAction = new CCMoveTo(timeToTake, distance); //this action moves the object 196 in x-direction within 5 seconds var removeAction = new CCRemoveSelf(); //this action removes the object //define sequence of actions and apply to object var cc_seq1 = new CCSequence(sendPackageAction, removeAction); pp.RunAction(cc_seq1); } }
public override void OnEnter() { base.OnEnter(); m_pInScene.Scale = 0.001f; m_pOutScene.Scale = 1.0f; m_pInScene.AnchorPoint = new CCPoint(0.5f, 0.5f); m_pOutScene.AnchorPoint = new CCPoint(0.5f, 0.5f); CCActionInterval rotozoom = new CCSequence( new CCSpawn( new CCScaleBy(m_fDuration / 2, 0.001f), new CCRotateBy(m_fDuration / 2, 360 * 2) ), new CCDelayTime(m_fDuration / 2) ); m_pOutScene.RunAction(rotozoom); m_pInScene.RunAction( new CCSequence( rotozoom.Reverse(), new CCCallFunc((Finish)) ) ); }
public override void onEnter() { base.onEnter(); centerSprites(1); CCAnimation animation = CCAnimation.animation(); string frameName; for (int i = 1; i < 15; i++) { if (i < 10) { frameName = string.Format("Images/grossini_dance_0{0}", i); } else { frameName = string.Format("Images/grossini_dance_{0}", i); } animation.addFrameWithFileName(frameName); } CCActionInterval action = CCAnimate.actionWithDuration(3.0f, animation, false); CCFiniteTimeAction action_back = action.reverse(); m_grossini.runAction(CCSequence.actions(action, action_back)); }
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 override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; m_pInScene.Scale = 0.5f; m_pInScene.Position = new CCPoint(s.Width, 0); m_pInScene.AnchorPoint = new CCPoint(0.5f, 0.5f); m_pOutScene.AnchorPoint = new CCPoint(0.5f, 0.5f); CCActionInterval jump = new CCJumpBy(m_fDuration / 4, new CCPoint(-s.Width, 0), s.Width / 4, 2); CCActionInterval scaleIn = new CCScaleTo(m_fDuration / 4, 1.0f); CCActionInterval scaleOut = new CCScaleTo(m_fDuration / 4, 0.5f); CCSequence jumpZoomOut = (CCSequence.FromActions(scaleOut, jump)); CCSequence jumpZoomIn = (CCSequence.FromActions((CCActionInterval)jump.Copy(), scaleIn)); CCActionInterval delay = new CCDelayTime(m_fDuration / 2); m_pOutScene.RunAction(jumpZoomOut); m_pInScene.RunAction ( CCSequence.FromActions ( delay, jumpZoomIn, new CCCallFunc(Finish) ) ); }
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 override void OnEnter() { base.OnEnter(); m_pInScene.Scale = 0.001f; m_pOutScene.Scale = 1.0f; m_pInScene.AnchorPoint = new CCPoint(0.5f, 0.5f); m_pOutScene.AnchorPoint = new CCPoint(0.5f, 0.5f); CCActionInterval rotozoom = CCSequence.FromActions ( CCSpawn.FromActions ( new CCScaleBy(m_fDuration / 2, 0.001f), new CCRotateBy(m_fDuration / 2, 360 * 2) ), new CCDelayTime(m_fDuration / 2) ); m_pOutScene.RunAction(rotozoom); m_pInScene.RunAction ( CCSequence.FromActions ( rotozoom.Reverse(), new CCCallFunc((Finish)) ) ); }
public override void OnEnter() { base.OnEnter(); CCNode target = GetChildByTag(EffectAdvanceScene.kTagBackground); // To reuse a grid the grid size and the grid type must be the same. // in this case: // ShakyTiles is TiledGrid3D and it's size is (15,10) // Shuffletiles is TiledGrid3D and it's size is (15,10) // TurnOfftiles is TiledGrid3D and it's size is (15,10) CCActionInterval shaky = new CCShakyTiles3D(4, false, new CCGridSize(15, 10), 5); CCActionInterval shuffle = new CCShuffleTiles(0, new CCGridSize(15, 10), 3); CCActionInterval turnoff = new CCTurnOffTiles(0, new CCGridSize(15, 10), 3); CCFiniteTimeAction turnon = turnoff.Reverse(); // reuse 2 times: // 1 for shuffle // 2 for turn off // turnon tiles will use a new grid CCFiniteTimeAction reuse = new CCReuseGrid(2); CCActionInterval delay = new CCDelayTime(1); // id orbit = [OrbitCamera::actionWithDuration:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90]; // id orbit_back = [orbit reverse]; // // [target runAction: [RepeatForever::actionWithAction: [Sequence actions: orbit, orbit_back, nil]]]; target.RunAction((CCSequence.FromActions(shaky, delay, reuse, shuffle, (CCFiniteTimeAction)delay.Copy(), turnoff, turnon))); }
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); }
CCSprite AddLocalBanana() { var banana = new CCSprite("BananaLocal"); banana.Tag = 0; double rnd = new Random().NextDouble(); double randomX = (rnd > 0) ? rnd * CCDirector.SharedDirector.WinSize.Width - banana.ContentSize.Width / 2 : banana.ContentSize.Width / 2; banana.Position = new CCPoint((float)randomX, CCDirector.SharedDirector.WinSize.Height - banana.ContentSize.Height / 2); byte[] message = buildBananaMessage((float)randomX); sendWarpUpdate(message); AddChild(banana); var moveBanana = new CCMoveTo(5.0f, new CCPoint(banana.Position.X, 0)); var moveBananaComplete = new CCCallFuncN((node) => { node.RemoveFromParentAndCleanup(true); localBananas.Remove(banana); }); var moveBananaSequence = new CCSequence(moveBanana, moveBananaComplete); banana.RunAction(moveBananaSequence); return(banana); }
public Hello3D() { CC3FbxGeneric hero = new CC3FbxGeneric("cocos2d-unity-demo/3D/Prefabs/Hero"); hero.setUnityLayerRecursively("3D"); hero.position3D = new Vector3(CCDirector.sharedDirector.winSize.x / 2, CCDirector.sharedDirector.winSize.y / 2 - 30, -700); hero.rotationY = 180; addChild(hero); hero.eventHandler = delegate(AnimationEvent evt){ if (evt.stringParameter == "End") { hero.playAnimation("Idle"); } }; var delay = new CCDelayTime(3f); var attack = new CCCallBlock(delegate { hero.playAnimation("Punch"); }); var seq = CCSequence.Actions(delay, attack); var repeat = new CCRepeatForever(seq as CCActionInterval); hero.runAction(repeat); }
public override void OnEnter() { base.OnEnter(); CCSize size = Layer.VisibleBoundsWorldspace.Size; // The .png image MUST be power of 2 in order to create a continue effect. // eg: 32x64, 512x128, 256x1024, 64x64, etc.. var sprite = new CCSprite("Images/pattern1.png", new CCRect(0, 0, 4096, 4096)); AddChild(sprite, -1, (int)enumTag.kTagSprite1); sprite.Position = new CCPoint(size.Width / 2, size.Height / 2); // Cocos2D-XNA no longer uses TexParameters. Please use the XNA SamplerState // sprite.Texture.TexParameters = new CCTexParams() { MagFilter = (uint)All.Linear, // MinFilter = (uint)All.Linear, // WrapS = (uint)All.Repeat, // WrapT = (uint)All.Repeat // }; sprite.Texture.SamplerState = SamplerState.LinearWrap; var rotate = new CCRotateBy(4, 360); sprite.RunAction(rotate); var scale = new CCScaleBy(2, 0.04f); var scaleBack = (CCScaleBy)scale.Reverse(); var seq = new CCSequence(scale, scaleBack); sprite.RunAction(seq); }
private void performanceActions20(CCSprite pSprite) { Random random = new Random(); CCSize size = CCDirector.sharedDirector().getWinSize(); if (random.Next() < 0.2f) { pSprite.position = new CCPoint((random.Next() % (int)size.width), (random.Next() % (int)size.height)); } else { pSprite.position = new CCPoint(-1000, -1000); } float period = 0.5f + (random.Next() % 1000) / 500.0f; CCRotateBy rot = CCRotateBy.actionWithDuration(period, 360.0f * random.Next()); CCActionInterval rot_back = null; CCAction permanentRotation = CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions(rot, rot_back)); pSprite.runAction(permanentRotation); float growDuration = 0.5f + (random.Next() % 1000) / 500.0f; CCActionInterval grow = CCScaleBy.actionWithDuration(growDuration, 0.5f, 0.5f); CCAction permanentScaleLoop = CCRepeatForever.actionWithAction(CCSequence.actionOneTwo(grow, grow.reverse())); pSprite.runAction(permanentScaleLoop); }
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)CCSequence.FromActions(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(); CCActionInterval inA, outA; m_pInScene.Visible = false; float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; if (m_eOrientation == CCTransitionOrientation.RightOver) { inDeltaZ = 90; inAngleZ = 270; outDeltaZ = 90; outAngleZ = 0; } else { inDeltaZ = -90; inAngleZ = 90; outDeltaZ = -90; outAngleZ = 0; } inA = new CCSequence ( new CCDelayTime (m_fDuration / 2), new CCSpawn ( new CCOrbitCamera(m_fDuration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0), new CCScaleTo(m_fDuration / 2, 1), new CCShow() ), new CCShow(), new CCCallFunc(Finish) ); outA = new CCSequence ( new CCSpawn ( new CCOrbitCamera(m_fDuration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0), new CCScaleTo(m_fDuration / 2, 0.5f) ), new CCHide(), new CCDelayTime (m_fDuration / 2) ); m_pInScene.Scale = 0.5f; m_pInScene.RunAction(inA); m_pOutScene.RunAction(outA); }
public LayerPriorityTest() { // Testing empty menu CCMenu menu1 = new CCMenu(); CCMenu menu2 = new CCMenu(); // Menu 1 CCMenuItemFont.DefaultFontName = "Marker Felt"; CCMenuItemFont.DefaultFontSize = 18; CCMenuItemFont item1 = new CCMenuItemFont ("Return to Main Menu", delegate { CCDirector.SharedDirector ().PopScene (); }); CCMenuItemFont item2 = new CCMenuItemFont ("Disable menu for 5 seconds", delegate (NSObject ob) { menu1.Enabled = false; CCDelayTime wait = new CCDelayTime(5); CCCallBlockO enable = new CCCallBlockO ( delegate (NSObject obj) { CCMenu obj1 = (CCMenu)obj; obj1.Enabled = true; }, menu1); CCSequence seq = new CCSequence (wait, enable); menu1.RunAction (seq); }); menu1.AddChild (item1); menu1.AddChild (item2); menu1.AlignItemsVerticallyWithPadding (2); this.AddChild (menu1); // Menu 2 bool priority = true; CCMenuItemFont.DefaultFontSize = 48; item1 = new CCMenuItemFont("Toggle Priority", delegate { if (priority == true) { menu2.SetHandlerPriority (-128 + 20); priority = false; } else { menu2.SetHandlerPriority (-128 - 20); priority = true; } }); item1.Color = new ccColor3B(0, 0, 255); menu2.AddChild (item1); this.AddChild (menu2); }
public override void OnEnter() { base.OnEnter(); InitScenes(); CCActionInterval incAction = Action(); CCActionInterval outcAction = Action(); CCFiniteTimeAction inAction = EaseAction(incAction); CCActionInterval outAction = new CCSequence ( EaseAction(outcAction), new CCCallFunc((Finish)) ); m_pInScene.RunAction(inAction); m_pOutScene.RunAction(outAction); }
public override void OnEnter() { base.OnEnter(); SetupTransition(); // create a transparent color layer // in which we are going to add our rendertextures CCSize size = CCDirector.SharedDirector.WinSize; // create the second render texture for outScene CCRenderTexture texture = new CCRenderTexture((int) size.Width, (int) size.Height); texture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); texture.Position = new CCPoint(size.Width / 2, size.Height / 2); texture.AnchorPoint = new CCPoint(0.5f, 0.5f); // render outScene to its texturebuffer texture.Clear(0, 0, 0, 1); texture.Begin(); m_pSceneToBeModified.Visit(); texture.End(); // Since we've passed the outScene to the texture we don't need it. if (m_pSceneToBeModified == m_pOutScene) { HideOutShowIn(); } // We need the texture in RenderTexture. CCProgressTimer node = ProgressTimerNodeWithRenderTexture(texture); // create the blend action CCSequence layerAction = new CCSequence( new CCProgressFromTo(m_fDuration, m_fFrom, m_fTo), new CCCallFunc(Finish) ); // run the blend action node.RunAction(layerAction); // add the layer (which contains our two rendertextures) to the scene AddChild(node, 2, kCCSceneRadial); }
public override void OnEnter() { base.OnEnter(); m_pInScene.Visible = false; CCActionInterval split = Action(); CCActionInterval seq = new CCSequence( split, new CCCallFunc((HideOutShowIn)), split.Reverse() ); RunAction( new CCSequence( EaseAction(seq), new CCCallFunc(Finish), new CCStopGrid() ) ); }
protected override void InitialiseScenes() { base.InitialiseScenes(); var bounds = Layer.VisibleBoundsWorldspace; InSceneNodeContainer.Scale = 0.5f; InSceneNodeContainer.Position = new CCPoint(bounds.Origin.X + bounds.Size.Width, bounds.Origin.Y); InSceneNodeContainer.AnchorPoint = new CCPoint(0.5f, 0.5f); OutSceneNodeContainer.AnchorPoint = new CCPoint(0.5f, 0.5f); InSceneNodeContainer.IgnoreAnchorPointForPosition = true; OutSceneNodeContainer.IgnoreAnchorPointForPosition = true; CCJumpBy jump = new CCJumpBy (Duration / 4, new CCPoint(-bounds.Size.Width, 0), bounds.Size.Width / 4, 2); CCFiniteTimeAction scaleIn = new CCScaleTo(Duration / 4, 1.0f); CCFiniteTimeAction scaleOut = new CCScaleTo(Duration / 4, 0.5f); jumpZoomOut = (new CCSequence(scaleOut, jump)); jumpZoomIn = (new CCSequence(jump, scaleIn)); delay = new CCDelayTime (Duration / 2); }
public MenuTest() { CCDirector director = CCDirector.SharedDirector (); SizeF size = director.WinSize (); CCMenu menu = null; CCSprite spriteNormal = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 2, 115, 23)); CCSprite spriteSelected = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 1, 115, 23)); CCSprite spriteDisabled = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 0, 115, 23)); CCMenuItemSprite item1 = new CCMenuItemSprite (spriteNormal, spriteSelected, spriteDisabled, delegate (NSObject sender) { CCScene scene1 = new CCScene (); scene1.AddChild (Layer2.Node()); CCDirector.SharedDirector ().ReplaceScene (scene1); }); CCMenuItemImage item2 = new CCMenuItemImage ("SendScoreButton.png", "SendScoreButtonPressed.png", null, cb); CCLabelAtlas labelAtlas = new CCLabelAtlas ("0123456789", "fps_images.png", 12, 32, '.'); CCMenuItemLabel item3 = new CCMenuItemLabel(labelAtlas, delegate (NSObject sender) { CCDirector.SharedDirector ().EventDispatcher.AddMouseDelegate (this, -128-1); this.Schedule (new MonoMac.ObjCRuntime.Selector ("allowTouches"), 5.0f); }); item3.DisabledColor = new ccColor3B (32, 32, 64); item3.Color = new ccColor3B (200, 200, 255); disabledItem = item3; CCMenuItemFont item4 = new CCMenuItemFont ("I toggle enabled items", delegate { disabledItem.Enabled = !disabledItem.Enabled; } ); item4.FontSize = 20; item4.FontName = "Marker Felt"; CCLabelBMFont label = new CCLabelBMFont ("configuration", "bitmapFontTest3.fnt"); CCMenuItemLabel item5 = new CCMenuItemLabel (label, delegate { CCScene scene = new CCScene (); scene.AddChild (new Layer4 ()); CCDirector.SharedDirector ().ReplaceScene (scene); }); item5.Scale = 0.8f; CCMenuItemFont.DefaultFontName = "Marker Felt"; CCMenuItemFont item6 = new CCMenuItemFont ("Priority Test", delegate (NSObject sender) { CCScene scene = new CCScene(); scene.AddChild (new LayerPriorityTest()); CCDirector.SharedDirector ().PushScene (scene); }); CCMenuItemFont.DefaultFontName = "Courier New"; CCMenuItemFont.DefaultFontSize = 30; CCMenuItemFont item7 = new CCMenuItemFont ("Quit", delegate { director.View.Window.Close (); }); CCTintBy color_action = new CCTintBy(0.5f, 0, -255, -255); var color_back = color_action.Reverse (); var seq = new CCSequence (color_action, color_back); item7.RunAction (new CCRepeatForever (seq)); menu = new CCMenu (item1, item2, item3, item4, item5, item6, item7); menu.AlignItemsVertically (); for (uint i = 0; i < menu.Children.Count(); i++) { CCNode child = (CCNode)menu.Children.ObjectAtIndex(i); PointF dstPoint = child.Position; int offset = (int)(size.Width/2) + 50; if (i % 2 == 0) offset = -offset; child.Position = new PointF(dstPoint.X + offset, dstPoint.Y); child.RunAction(new CCEaseElasticOut( new CCMoveBy(2, new PointF(dstPoint.X - offset, 0)), 0.35f)); } menu.Position = new PointF(size.Width/2, size.Height/2); this.AddChild(menu); }
protected override void InitialiseScenes() { base.InitialiseScenes(); // create a transparent color layer // in which we are going to add our rendertextures var color = new CCColor4B(0, 0, 0, 0); var bounds = Layer.VisibleBoundsWorldspace; CCRect viewportRect = Viewport.ViewportInPixels; // create the first render texture for inScene CCRenderTexture inTexture = new CCRenderTexture(bounds.Size, viewportRect.Size); if (null == inTexture) { return; } inTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); inTexture.Position = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2); inTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(inTexture); // render inScene to its texturebuffer inTexture.Begin(); InSceneNodeContainer.Visit(); inTexture.End(); // create the second render texture for outScene CCRenderTexture outTexture = new CCRenderTexture(bounds.Size, viewportRect.Size); outTexture.Sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); outTexture.Position = new CCPoint(bounds.Origin.X + bounds.Size.Width / 2, bounds.Size.Height / 2); outTexture.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(outTexture); // render outScene to its texturebuffer outTexture.Begin(); OutSceneNodeContainer.Visit(); outTexture.End(); // create blend functions var blend1 = new CCBlendFunc(CCOGLES.GL_ONE, CCOGLES.GL_ONE); // inScene will lay on background and will not be used with alpha var blend2 = CCBlendFunc.NonPremultiplied; // we are going to blend outScene via alpha inTexture.Sprite.BlendFunc = blend1; outTexture.Sprite.BlendFunc = blend2; inTexture.Sprite.Opacity = 255; outTexture.Sprite.Opacity = 255; CCAction layerAction = new CCSequence ( new CCFadeTo (Duration, 0), new CCCallFunc((Finish)) ); outTexture.Sprite.RunAction(layerAction); InSceneNodeContainer.Visible = false; OutSceneNodeContainer.Visible = false; }