public override void OnEnter() { base.OnEnter(); var s = CCDirector.SharedDirector.WinSize; // rotate and jump var jump1 = new CCJumpBy(4, new CCPoint(-s.Width + 80, 0), 100, 4); var jump2 = jump1.Reverse(); var rot1 = new CCRotateBy(4, 360 * 2); var rot2 = rot1.Reverse(); var seq3_1 = CCSequence.FromActions(jump2, jump1); var seq3_2 = CCSequence.FromActions(rot1, rot2); var spawn = CCSpawn.FromActions(seq3_1, seq3_2); var action = new CCSpeed(new CCRepeatForever(spawn), 1.0f); action.Tag = EaseTest.kTagAction1; var action2 = (CCAction)(action.Copy()); var action3 = (CCAction)(action.Copy()); action2.Tag = EaseTest.kTagAction1; action3.Tag = EaseTest.kTagAction1; m_grossini.RunAction(action2); m_tamara.RunAction(action3); m_kathia.RunAction(action); Schedule(altertime, 1.0f); }
private void performanceActions20(CCSprite pSprite) { CCSize size = Layer.VisibleBoundsWorldspace.Size; 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 = (CCFiniteTimeAction)rot.Reverse(); CCAction permanentRotation = new CCRepeatForever(new CCSequence(rot, rot_back)); pSprite.RunAction(permanentRotation); float growDuration = 0.5f + (CCRandom.Next() % 1000) / 500.0f; CCFiniteTimeAction grow = new CCScaleBy(growDuration, 0.5f, 0.5f); CCAction permanentScaleLoop = new CCRepeatForever(new CCSequence(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 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); }
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 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 SpriteBatchNodeChildrenChildren() { CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/ghosts.plist"); var rot = new CCRotateBy(10, 360); seq = new CCRepeatForever(rot); var rot_back = rot.Reverse(); rot_back_fe = new CCRepeatForever(rot_back); // SpriteBatchNode: 3 levels of children aParent = new CCSpriteBatchNode("animations/ghosts"); AddChild(aParent); // parent l1 = new CCSprite("father.gif"); aParent.AddChild(l1); // child left l2a = new CCSprite("sister1.gif"); l1.AddChild(l2a); // child right l2b = new CCSprite("sister2.gif"); l1.AddChild(l2b); // child left bottom l3a1 = new CCSprite("child1.gif"); l3a1.Scale = 0.45f; l2a.AddChild(l3a1); // child left top l3a2 = new CCSprite("child1.gif"); l3a2.Scale = 0.45f; l2a.AddChild(l3a2); // child right bottom l3b1 = new CCSprite("child1.gif"); l3b1.Scale = 0.45f; l3b1.FlipY = true; l2b.AddChild(l3b1); // child right top l3b2 = new CCSprite("child1.gif"); l3b2.Scale = 0.45f; l3b2.FlipY = true; l2b.AddChild(l3b2); }
public Sprite6() { // SpriteBatchNode actions rotate = new CCRotateBy(5, 360); action = new CCRepeatForever(rotate); // SpriteBatchNode actions rotate_back = rotate.Reverse(); scale = new CCScaleBy(5, 1.5f); scale_back = scale.Reverse(); for (int i = 0; i < 3; i++) { CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * i, 121 * 1, 85, 121)); AddChild(sprite, i); } }
public override void OnEnter() { base.OnEnter(); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCSprite sprite = new CCSprite(s_pPathGrossini); CCSprite spriteSister1 = new CCSprite(s_pPathSister1); CCSprite spriteSister2 = new CCSprite(s_pPathSister2); sprite.Scale = (1.5f); spriteSister1.Scale = (1.5f); spriteSister2.Scale = (1.5f); sprite.Position = (new CCPoint(x / 2, y / 2)); spriteSister1.Position = (new CCPoint(40, y / 2)); spriteSister2.Position = (new CCPoint(x - 40, y / 2)); CCAction rot = new CCRotateBy(16, -3600); AddChild(sprite); AddChild(spriteSister1); AddChild(spriteSister2); sprite.RunAction(rot); CCActionInterval jump1 = new CCJumpBy(4, new CCPoint(-400, 0), 100, 4); CCActionInterval jump2 = (CCActionInterval)jump1.Reverse(); CCActionInterval rot1 = new CCRotateBy(4, 360 * 2); CCActionInterval rot2 = (CCActionInterval)rot1.Reverse(); spriteSister1.RunAction(new CCRepeat(new CCSequence(jump2, jump1), 5)); spriteSister2.RunAction(new CCRepeat(new CCSequence((CCFiniteTimeAction)(jump1.Copy()), (CCFiniteTimeAction)(jump2.Copy())), 5)); spriteSister1.RunAction(new CCRepeat(new CCSequence(rot1, rot2), 5)); spriteSister2.RunAction(new CCRepeat(new CCSequence((CCFiniteTimeAction)(rot2.Copy()), (CCFiniteTimeAction)(rot1.Copy())), 5)); }
public Sprite6() { // small capacity. Testing resizing // Don't use capacity=1 in your real game. It is expensive to resize the capacity CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1); AddChild(batch, 0, kTagSpriteBatchNode); batch.IgnoreAnchorPointForPosition = true; CCSize s = CCDirector.SharedDirector.WinSize; batch.AnchorPoint = new CCPoint(0.5f, 0.5f); batch.ContentSize = (new CCSize(s.Width, s.Height)); // SpriteBatchNode actions CCActionInterval rotate = new CCRotateBy(5, 360); CCAction action = new CCRepeatForever(rotate); // SpriteBatchNode actions CCActionInterval rotate_back = (CCActionInterval)rotate.Reverse(); CCActionInterval rotate_seq = (CCActionInterval)(CCSequence.FromActions(rotate, rotate_back)); CCAction rotate_forever = new CCRepeatForever(rotate_seq); CCActionInterval scale = new CCScaleBy(5, 1.5f); CCActionInterval scale_back = (CCActionInterval)scale.Reverse(); CCActionInterval scale_seq = (CCActionInterval)(CCSequence.FromActions(scale, scale_back)); CCAction scale_forever = new CCRepeatForever(scale_seq); float step = s.Width / 4; for (int i = 0; i < 3; i++) { CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121)); sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2)); sprite.RunAction((CCAction)(action.Copy())); batch.AddChild(sprite, i); } batch.RunAction(scale_forever); batch.RunAction(rotate_forever); }
public override void OnEnter() { base.OnEnter(); centerSprites(3); var actionTo = new CCRotateTo(2, 45); var actionTo2 = new CCRotateTo(2, -45); var actionTo0 = new CCRotateTo(2, 0); m_tamara.RunAction(CCSequence.FromActions(actionTo, actionTo0)); var actionBy = new CCRotateBy(2, 360); var actionByBack = actionBy.Reverse(); m_grossini.RunAction(CCSequence.FromActions(actionBy, actionByBack)); // m_kathia->runAction( CCSequence::actions(actionTo2, actionTo0->copy()->autorelease(), NULL)); m_kathia.RunAction(CCSequence.FromActions(actionTo2, (CCActionInterval)actionTo0.Copy())); }
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)); var rot = new CCRotateBy(2, 360); var rot_back = rot.Reverse(); var forever = new CCRepeatForever(rot, rot_back) { Tag = 101 }; // Since Actions are immutable to set the tag differently we need to // create a new action. Notice that the same actions can be used in // this case instead of copying them as well. forever2 = new CCRepeatForever(rot, rot_back) { 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 Sprite6() { // small capacity. Testing resizing // Don't use capacity=1 in your real game. It is expensive to resize the capacity batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1); AddChild(batch, 0, tagSpriteBatchNode); // SpriteBatchNode actions rotate = new CCRotateBy(5, 360); action = new CCRepeatForever(rotate); // SpriteBatchNode actions rotate_back = rotate.Reverse(); scale = new CCScaleBy(5, 1.5f); scale_back = scale.Reverse(); for (int i = 0; i < 3; i++) { CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121)); batch.AddChild(sprite, i); } }
public override void OnEnter() { base.OnEnter(); var s = Layer.VisibleBoundsWorldspace.Size; // rotate and jump var jump1 = new CCJumpBy(4, new CCPoint(-s.Width + 80, 0), 100, 4); var jump2 = jump1.Reverse(); var rot1 = new CCRotateBy(4, 360 * 2); var rot2 = rot1.Reverse(); var seq3_1 = new CCSequence(jump2, jump1); var seq3_2 = new CCSequence(rot1, rot2); var spawn = new CCSpawn(seq3_1, seq3_2); speedAction1 = new CCSpeed(new CCRepeatForever(spawn), 1.0f); speedAction2 = new CCSpeed(new CCRepeatForever(spawn), 2.0f); speedAction3 = new CCSpeed(new CCRepeatForever(spawn), 0.5f); m_grossini.RunAction(speedAction1); m_tamara.RunAction(speedAction2); m_kathia.RunAction(speedAction3); }
private async Task RotatePlayButtons(bool clockwise, Action callback) { float timePerMove = 1.5f; //var signalUpLeft = _cordinatesGenerator.PositionAndSquare[PositionInGame.SignalUpLeft]; //var signalUpRight = _cordinatesGenerator.PositionAndSquare[PositionInGame.SignalUpRight]; //var signalDownLeft = _cordinatesGenerator.PositionAndSquare[PositionInGame.SignalDownLeft]; //var signalDownRight = _cordinatesGenerator.PositionAndSquare[PositionInGame.SignalDownRight]; playUpLeft = _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpLeft]; playUpRight = _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpRight]; playDownLeft = _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownLeft]; playDownRight = _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownRight]; var moveToUpLeft = new CCMoveTo(timePerMove, new CCPoint(playUpLeft.Position.X, playUpLeft.Position.Y)); var moveToUpRight = new CCMoveTo(timePerMove, new CCPoint(playUpRight.Position.X, playUpRight.Position.Y)); var moveToDownRight = new CCMoveTo(timePerMove, new CCPoint(playDownRight.Position.X, playDownRight.Position.Y)); var moveToDownLeft = new CCMoveTo(timePerMove, new CCPoint(playDownLeft.Position.X, playDownLeft.Position.Y)); var moveCompletedAction = new CCCallFunc(callback); CCSequence mySequence = new CCSequence(moveToDownRight, moveCompletedAction); CCRotateBy rotate = new CCRotateBy(0.5f, 45); var rotateBack = rotate.Reverse(); await DiagonalSquares(rotate); await MoveHalfWay(timePerMove); //var halfMoveCompletedAction = new CCCallFunc(() => //{ _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpLeft] = playDownLeft; _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpRight] = playUpLeft; _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownLeft] = playDownRight; _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownRight] = playUpRight; playUpLeft.RunAction(moveToUpRight); playDownRight.RunAction(moveToDownLeft); playDownLeft.RunAction(moveToUpLeft); await playUpRight.RunActionAsync(mySequence); //await DiagonalSquares(rotateBack, callback); //}); //} //else //{ // playUpLeft.RunAction(moveToDownLeft); // playUpRight.RunAction(moveToUpLeft); // playDownRight.RunAction(moveToUpRight); // playDownLeft.RunAction(mySequence); // _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpLeft] = playUpRight; // _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayUpRight] = playDownRight; // _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownLeft] = playUpLeft; // _cordinatesGenerator.PositionAndSquare[PositionInGame.PlayDownRight] = playDownLeft; //} }
public SpriteBatchNodeChildren() { CCSize s = CCDirector.SharedDirector.WinSize; // parents CCSpriteBatchNode batch = new CCSpriteBatchNode("animations/grossini", 50); AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist"); CCSprite sprite1 = new CCSprite("grossini_dance_01.png"); sprite1.Position = (new CCPoint(s.Width / 3, s.Height / 2)); CCSprite sprite2 = new CCSprite("grossini_dance_02.png"); sprite2.Position = (new CCPoint(50, 50)); CCSprite sprite3 = new CCSprite("grossini_dance_03.png"); sprite3.Position = (new CCPoint(-50, -50)); batch.AddChild(sprite1); sprite1.AddChild(sprite2); sprite1.AddChild(sprite3); // BEGIN NEW CODE var animFrames = new List <CCSpriteFrame>(); string str = ""; for (int i = 1; i < 15; i++) { string temp = ""; if (i < 10) { temp = "0" + i; } else { temp = i.ToString(); } str = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str); animFrames.Add(frame); } CCAnimation animation = new CCAnimation(animFrames, 0.2f); sprite1.RunAction(new CCRepeatForever(new CCAnimate(animation))); // END NEW CODE CCActionInterval action = new CCMoveBy(2, new CCPoint(200, 0)); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCActionInterval action_rot = new CCRotateBy(2, 360); CCActionInterval action_s = new CCScaleBy(2, 2); CCActionInterval action_s_back = (CCActionInterval)action_s.Reverse(); CCActionInterval seq2 = (CCActionInterval)action_rot.Reverse(); sprite2.RunAction(new CCRepeatForever(seq2)); sprite1.RunAction((CCAction)(new CCRepeatForever(action_rot))); sprite1.RunAction((CCAction)(new CCRepeatForever((CCActionInterval)(new CCSequence(action, action_back))))); sprite1.RunAction((CCAction)(new CCRepeatForever((CCActionInterval)(new CCSequence(action_s, action_s_back))))); }
public SpriteChildrenChildren() { CCSize s = CCDirector.SharedDirector.WinSize; CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/ghosts.plist"); CCNode aParent; CCSprite l1, l2a, l2b, l3a1, l3a2, l3b1, l3b2; CCActionInterval rot = new CCRotateBy(10, 360); CCAction seq = new CCRepeatForever(rot); CCActionInterval rot_back = (CCActionInterval)rot.Reverse(); CCAction rot_back_fe = new CCRepeatForever(rot_back); // // SpriteBatchNode: 3 levels of children // aParent = new CCNode(); AddChild(aParent); // parent l1 = new CCSprite("father.gif"); l1.Position = (new CCPoint(s.Width / 2, s.Height / 2)); l1.RunAction((CCAction)(seq.Copy())); aParent.AddChild(l1); CCSize l1Size = l1.ContentSize; // child left l2a = new CCSprite("sister1.gif"); l2a.Position = (new CCPoint(-50 + l1Size.Width / 2, 0 + l1Size.Height / 2)); l2a.RunAction((CCAction)(rot_back_fe.Copy())); l1.AddChild(l2a); CCSize l2aSize = l2a.ContentSize; // child right l2b = new CCSprite("sister2.gif"); l2b.Position = (new CCPoint(+50 + l1Size.Width / 2, 0 + l1Size.Height / 2)); l2b.RunAction((CCAction)(rot_back_fe.Copy())); l1.AddChild(l2b); CCSize l2bSize = l2a.ContentSize; // child left bottom l3a1 = new CCSprite("child1.gif"); l3a1.Scale = 0.45f; l3a1.Position = new CCPoint(0 + l2aSize.Width / 2, -100 + l2aSize.Height / 2); l2a.AddChild(l3a1); // child left top l3a2 = new CCSprite("child1.gif"); l3a2.Scale = 0.45f; l3a1.Position = (new CCPoint(0 + l2aSize.Width / 2, +100 + l2aSize.Height / 2)); l2a.AddChild(l3a2); // child right bottom l3b1 = new CCSprite("child1.gif"); l3b1.Scale = 0.45f; l3b1.FlipY = true; l3b1.Position = (new CCPoint(0 + l2bSize.Width / 2, -100 + l2bSize.Height / 2)); l2b.AddChild(l3b1); // child right top l3b2 = new CCSprite("child1.gif"); l3b2.Scale = 0.45f; l3b2.FlipY = true; l3b1.Position = new CCPoint(0 + l2bSize.Width / 2, +100 + l2bSize.Height / 2); l2b.AddChild(l3b2); }