private void performanceActions(CCSprite pSprite) { CCSize size = Layer.VisibleBoundsWorldspace.Size; pSprite.Position = new CCPoint((CCRandom.Next() % (int) size.Width), (CCRandom.Next() % (int) size.Height)); float period = 0.5f + (CCRandom.Next() % 1000) / 500.0f; CCRotateBy rot = new CCRotateBy (period, 360.0f * CCRandom.Float_0_1()); var rot_back = 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 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); }
void AddNewSpriteWithCoords(CCPoint p) { CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode); int idx = (int)(CCRandom.NextDouble() * 1400 / 100); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121)); sprite.Position = (new CCPoint(p.X, p.Y)); BatchNode.AddChild(sprite); CCFiniteTimeAction action = null; float random = (float)CCRandom.NextDouble(); if (random < 0.20) action = new CCScaleBy(3, 2); else if (random < 0.40) action = new CCRotateBy (3, 360); else if (random < 0.60) action = new CCBlink (1, 3); else if (random < 0.8) action = new CCTintBy (2, 0, -255, -255); else action = new CCFadeOut (2); CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse(); CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
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 override void OnEnter() { base.OnEnter(); float x, y; CCSize size = Layer.VisibleBoundsWorldspace.Size; x = size.Width; y = size.Height; CCSprite sprite = new CCSprite(grossini); CCSprite spriteSister1 = new CCSprite(sister1); CCSprite spriteSister2 = new CCSprite(sister2); sprite.Scale = 1.5f; spriteSister1.Scale = 1.5f; spriteSister2.Scale = 1.5f; sprite.Position = size.Center; spriteSister1.Position = (new CCPoint(40, y / 2)); spriteSister2.Position = (new CCPoint(x - 40, y / 2)); AddChild(sprite); AddChild(spriteSister1); AddChild(spriteSister2); sprite.RunAction(rot); spriteSister1.Repeat (5, jump2, jump1); spriteSister2.Repeat (5, jump1, jump2); spriteSister1.Repeat (5, rot1, rot2); spriteSister2.Repeat (5, rot2, rot1); }
public TextLayer() : base() { Camera = AppDelegate.SharedCamera; contentLayer = new CCLayer(); CCCamera contentCamera = new CCCamera(Camera.OrthographicViewSizeWorldspace, Camera.CenterInWorldspace, Camera.TargetInWorldspace); contentLayer.Camera = contentCamera; var bg = new CCSprite(TestResource.s_back3); BaseNode = bg; contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground); var Kathia = new CCSprite(TestResource.s_pPathSister2); BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia); var sc = new CCScaleBy(2, 5); var sc_back = sc.Reverse(); Kathia.RunAction(new CCRepeatForever(sc, sc_back)); var Tamara = new CCSprite(TestResource.s_pPathSister1); BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara); var sc2 = new CCScaleBy(2, 5); var sc2_back = sc2.Reverse(); Tamara.RunAction(new CCRepeatForever(sc2, sc2_back)); var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255)); contentLayer.AddChild(colorBackground, -1); }
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); }
public TextLayer() : base() { Color = new CCColor3B(32, 128, 32); Opacity = 255; BaseNode = new CCNodeGrid(); var effect = CurrentAction; BaseNode.RunAction(effect); AddChild(BaseNode, 0, EffectTestScene.kTagBackground); var bg = new CCSprite(TestResource.s_back3); BaseNode.AddChild(bg, 0); var Kathia = new CCSprite(TestResource.s_pPathSister2); BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia); var sc = new CCScaleBy(2, 5); var sc_back = sc.Reverse(); Kathia.RunAction(new CCRepeatForever(sc, sc_back)); var Tamara = new CCSprite(TestResource.s_pPathSister1); BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara); var sc2 = new CCScaleBy(2, 5); var sc2_back = sc2.Reverse(); Tamara.RunAction(new CCRepeatForever(sc2, sc2_back)); }
public TextLayer() : base() { contentLayer = new CCLayer(); CCCamera contentCamera = Camera; contentLayer.Camera = contentCamera; var bg = new CCSprite(TestResource.s_back3); BaseNode = bg; contentLayer.AddChild(bg, 0, EffectTestScene.kTagBackground); var Kathia = new CCSprite(TestResource.s_pPathSister2); BaseNode.AddChild(Kathia, 1, EffectTestScene.kTagKathia); var sc = new CCScaleBy(2, 5); var sc_back = sc.Reverse(); Kathia.RunAction(new CCRepeatForever(sc, sc_back)); var Tamara = new CCSprite(TestResource.s_pPathSister1); BaseNode.AddChild(Tamara, 1, EffectTestScene.kTagTamara); var sc2 = new CCScaleBy(2, 5); var sc2_back = sc2.Reverse(); Tamara.RunAction(new CCRepeatForever(sc2, sc2_back)); var colorBackground = new CCLayerColor(new CCColor4B(32, 128, 32, 255)); contentLayer.AddChild(colorBackground, -1); }
public IntervalLayer() { m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f; CCSize s = Layer.VisibleBoundsWorldspace.Size; // sun CCParticleSystem sun = new CCParticleSun(new CCPoint(s.Width / 2, s.Height / 2)); sun.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); sun.Position = (new CCPoint(s.Width - 32, s.Height - 32)); sun.TotalParticles = 130; sun.Life = (0.6f); AddChild(sun); // timers m_label0 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label1 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label2 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label3 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); m_label4 = new CCLabelBMFont("0", "fonts/bitmapFontTest4.fnt"); Schedule (); Schedule(step1); Schedule(step2, 0); Schedule(step3, 1.0f); Schedule(step4, 2.0f); m_label0.Position = new CCPoint(s.Width * 1 / 6, s.Height / 2); 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 = new CCSprite(s_pPathGrossini); sprite.Position = new CCPoint(40, 50); CCJumpBy jump = new CCJumpBy (3, new CCPoint(s.Width - 80, 0), 50, 4); AddChild(sprite); sprite.RunAction(new CCRepeatForever ( (CCFiniteTimeAction) (new CCSequence(jump, jump.Reverse()))) ); // pause button CCMenuItem item1 = new CCMenuItemFont("Pause", onPause); CCMenu menu = new CCMenu(item1); menu.Position = new CCPoint(s.Width / 2, s.Height - 50); AddChild(menu); }
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(); CCSize s = Layer.VisibleBoundsWorldspace.Size; CCSprite pGrossini = new CCSprite(s_pPathGrossini); AddChild(pGrossini, 0, (int)KTag.kTagGrossini); pGrossini.Position = new CCPoint(s.Width / 2, s.Height / 2); pGrossini.RunAction(new CCScaleBy(2, 2)); Application.ActionManager.PauseTarget(pGrossini); pGrossini.RunAction(new CCRotateBy (2, 360)); this.Schedule(resumeGrossini, 3.0f); }
public override void OnEnter() { base.OnEnter(); CCSprite grossini = new CCSprite(s_pPathGrossini); AddChild(grossini, 0, 2); grossini.Position = (new CCPoint(200, 200)); grossini.RunAction(new CCSequence( new CCMoveBy (1, new CCPoint(150, 0)), new CCCallFuncN(bugMe)) ); }
protected override void AddedToScene() { base.AddedToScene(); CCSize s = Layer.VisibleBoundsWorldspace.Size; CCSprite p = new CCSprite(TestResource.s_back3); AddChild(p, 0); p.Position = (new CCPoint(s.Width / 2, s.Height / 2)); //p.Opacity = 50; CCSprite sprite; CCOrbitCamera orbit; CCCamera cam; CCSize ss; // LEFT s = p.ContentSize; sprite = new CCSprite(TestResource.s_pPathGrossini); sprite.Scale = (0.5f); p.AddChild(sprite, 0); sprite.Position = (new CCPoint(s.Width / 4 * 1, s.Height / 2)); cam = sprite.Camera; orbit = new CCOrbitCamera(2, 1, 0, 0, 360, 0, 0); sprite.RunAction(new CCRepeatForever (orbit)); // CENTER sprite = new CCSprite(TestResource.s_pPathGrossini); sprite.Scale = 1.0f; p.AddChild(sprite, 0); sprite.Position = new CCPoint(s.Width / 4 * 2, s.Height / 2); orbit = new CCOrbitCamera(2, 1, 0, 0, 360, 45, 0); sprite.RunAction(new CCRepeatForever (orbit)); // RIGHT sprite = new CCSprite(TestResource.s_pPathGrossini); sprite.Scale = 2.0f; p.AddChild(sprite, 0); sprite.Position = new CCPoint(s.Width / 4 * 3, s.Height / 2); ss = sprite.ContentSize; orbit = new CCOrbitCamera(2, 1, 0, 0, 360, 90, -45); sprite.RunAction(new CCRepeatForever (orbit)); // PARENT orbit = new CCOrbitCamera(10, 1, 0, 0, 360, 0, 90); p.RunAction(new CCRepeatForever (orbit)); Scale = 1; }
public override void OnEnter() { base.OnEnter(); CCSprite child = new CCSprite(s_pPathGrossini); child.Position = Layer.VisibleBoundsWorldspace.Size.Center; AddChild(child, 1); //Sum of all action's duration is 1.5 second. child.RunAction(new CCRotateBy (1.5f, 90)); child.RunActions (new CCDelayTime (1.4f), new CCFadeOut (1.1f)); //After 1.5 second, self will be removed. RunActions (new CCDelayTime (1.4f), new CCCallFunc ((removeThis))); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; CCMoveBy pMove = new CCMoveBy (2, new CCPoint(200, 0)); CCCallFunc pCallback = new CCCallFunc(stopAction); CCFiniteTimeAction pSequence = (CCFiniteTimeAction)new CCSequence(pMove, pCallback); pSequence.Tag = (int)KTag.kTagSequence; CCSprite pChild = new CCSprite(s_pPathGrossini); pChild.Position = (new CCPoint(200, 200)); AddChild(pChild, 1, kTagGrossini); pChild.RunAction(pSequence); }
public MainLayer() { var listener = new CCEventListenerTouchAllAtOnce(); listener.OnTouchesEnded = onTouchesEnded; AddEventListener(listener); CCSprite sprite = new CCSprite(ClickAndMoveTest.s_pPathGrossini); CCLayer layer = new CCLayerColor(new CCColor4B(255, 255, 0, 255)); AddChild(layer, -1); AddChild(sprite, 0, ClickAndMoveTest.kTagSprite); sprite.Position = new CCPoint(20, 150); sprite.RunAction(new CCJumpTo (4, new CCPoint(300, 48), 100, 4)); layer.RepeatForever(new CCFadeIn(1), new CCFadeOut(1)); }
void AddNewSpriteWithCoords(CCPoint p) { int idx = (int)(CCMacros.CCRandomBetween0And1() * 1400.0f / 100.0f); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(x, y, 85, 121)); AddChild(sprite); sprite.Position = p; CCFiniteTimeAction action; float random = CCMacros.CCRandomBetween0And1(); if (random < 0.20) action = new CCScaleBy(3, 2); else if (random < 0.40) action = new CCRotateBy (3, 360); else if (random < 0.60) action = new CCBlink (1, 3); else if (random < 0.8) action = new CCTintBy (2, 0, -255, -255); else action = new CCFadeOut (2); object obj = action.Reverse(); CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse(); CCFiniteTimeAction seq = (CCFiniteTimeAction)(new CCSequence(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; // // Sprite 1: GL_LINEAR // // Default filter is GL_LINEAR CCSprite sprite = new CCSprite("Images/grossinis_sister1"); sprite.Position = new CCPoint(s.Width / 3.0f, s.Height / 2.0f); AddChild(sprite); // this is the default filterting sprite.IsAntialiased = true; // // Sprite 1: GL_NEAREST // CCSprite sprite2 = new CCSprite("Images/grossinis_sister2"); sprite2.Position = new CCPoint(2 * s.Width / 3.0f, s.Height / 2.0f); AddChild(sprite2); // Use Nearest in this one sprite2.IsAntialiased = false; // scale them to show var sc = new CCScaleBy(3, 8.0f); var sc_back = sc.Reverse(); CCRepeatForever scaleforever = new CCRepeatForever(sc, sc_back); sprite2.RunAction(scaleforever); sprite.RunAction(scaleforever); CCTextureCache.SharedTextureCache.DumpCachedTextureInfo(); }
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); }
public override void Setup() { CCClippingNode clipper = new CCClippingNode() { Tag = kTagClipperNode }; clipper.ContentSize = new CCSize(200, 200); clipper.AnchorPoint = new CCPoint(0.5f, 0.5f); AddChild(clipper); CCDrawNode stencil = new CCDrawNode(); CCPoint[] rectangle = { new CCPoint(0, 0), new CCPoint(clipper.ContentSize.Width, 0), new CCPoint(clipper.ContentSize.Width, clipper.ContentSize.Height), new CCPoint(0, clipper.ContentSize.Height), }; CCColor4F white = new CCColor4F(0, 0, 0, 1); stencil.DrawPolygon(rectangle, 4, white, 0, white); clipper.Stencil = stencil; CCSprite content = new CCSprite(TestResource.s_back2); content.Tag = kTagContentNode; content.AnchorPoint = new CCPoint(0.5f, 0.5f); clipper.AddChild(content); content.RunAction(new CCRepeatForever(new CCRotateBy(1, 45))); m_bScrolling = false; // Register Touch Event var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesBegan = onTouchesBegan; touchListener.OnTouchesMoved = onTouchesMoved; touchListener.OnTouchesEnded = onTouchesEnded; AddEventListener(touchListener); }
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 = parent.ContentSize.Center; 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 = clipper.ContentSize.Center; stencil.Visible = false; stencil.RunAction(new CCSequence(new CCDelayTime(i), new CCShow())); clipper.Stencil = stencil; clipper.AddChild(stencil); parent = clipper; } }
private void AddMonster(float time) { var selectedMonster = new Random().Next() % _monsters.Count; var monster = _monsters[selectedMonster]; var m = monster.Movement; //!IMPORTANT -- Every Sprite in Screen must be an new CCSprite! Each Sprite can only be one time on screen var spriteMonster = new CCSprite(monster.MonsterSprite); spriteMonster.Scale = _appScale; spriteMonster.Tag = monster.Tag; //BLOCK 1 - Determine where to spawn the monster along the Y axis var winSize = Window.WindowSizeInPixels; var minX = (spriteMonster.ContentSize.Width / 2); var maxX = winSize.Width - spriteMonster.ContentSize.Width / 2; var rangeX = maxX - minX; var actualY = (new Random().Next() % rangeX) + minX; //BLOCK 2 - Determine speed of the monster var minDuration = monster.MinVelocity; var maxDuration = monster.MaxVelocity; var rangeDuration = maxDuration - minDuration; var actualDuration = (new Random().Next() % rangeDuration) + minDuration; if(m == 1) { spriteMonster.Position = new CCPoint(actualY, winSize.Height + spriteMonster.ContentSize.Height/2); AddChild(spriteMonster); var actionMove = new CCMoveTo(actualDuration, new CCPoint(actualY, -spriteMonster.ContentSize.Height/2)); var actionMoveComplete = new CCCallFuncN (node => { _monstersOnScreen.Remove(node); node.RemoveFromParent(); _lives--; var index = _hearths.Count - 1; RemoveChild(_hearths[index]); _hearths.RemoveAt(index); if(_lives == 0) { Window.DefaultDirector.ReplaceScene(GameStartLayer.GameStartLayerScene(Window)); } }); spriteMonster.RunActions(actionMove, actionMoveComplete); _monstersOnScreen.Add(spriteMonster); } else if(m == 2) { spriteMonster.Position = new CCPoint(actualY, winSize.Height + spriteMonster.ContentSize.Height/2); AddChild(spriteMonster); var actionMoveComplete = new CCCallFuncN (node => { _monstersOnScreen.Remove(node); node.RemoveFromParent(); _lives--; var index = _hearths.Count - 1; RemoveChild(_hearths[index]); _hearths.RemoveAt(index); if(_lives == 0) { Window.DefaultDirector.ReplaceScene(GameStartLayer.GameStartLayerScene(Window)); } }); var bezierList = new List<CCFiniteTimeAction>(); var bezier = new CCBezierConfig(); var splitDuration = actualDuration / 6.0f; CCBezierTo bezierAction; for(int i = 0; i < 6; i++) { if(i % 2 == 0) { bezier.ControlPoint1 = new CCPoint(actualY + 100, winSize.Height - (100 + (i * 200))); bezier.ControlPoint2 = new CCPoint(actualY + 100, winSize.Height - (100 + (i * 200))); bezier.EndPosition = new CCPoint(actualY, winSize.Height - (200 + (i * 200))); bezierAction = new CCBezierTo(splitDuration, bezier); } else { bezier.ControlPoint1 = new CCPoint(actualY - 100, winSize.Height - (100 + (i * 200))); bezier.ControlPoint2 = new CCPoint(actualY - 100, winSize.Height - (100 + (i * 200))); bezier.EndPosition = new CCPoint(actualY, winSize.Height - (200 + (i * 200))); bezierAction = new CCBezierTo(splitDuration, bezier); } bezierList.Add(bezierAction); } bezierList.Add(actionMoveComplete); var seq = new CCSequence(bezierList.ToArray()); spriteMonster.RunAction(seq); _monstersOnScreen.Add(spriteMonster); } }
void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent) { var monstersToDelete = new List<CCNode>(); var touch = touches[0]; var touchLocation = Layer.ScreenToWorldspace(touch.LocationOnScreen); foreach(var monster in _monstersOnScreen) { if(monster.BoundingBox.ContainsPoint(touchLocation)) { monstersToDelete.Add(monster); var m = _monsters[monster.Tag]; var splashPool = new CCSprite(m.SplashSprite); if(m.KillMethod == 1) { splashPool.Position = monster.Position; AddChild(splashPool); var fade = new CCFadeOut(3.0f); var remove = new CCCallFuncN (RemoveSprite); var sequencia = new CCSequence(fade, remove); CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.7f; CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/SplatEffect"); splashPool.RunAction(sequencia); } else if(m.KillMethod == 2) { CCSimpleAudioEngine.SharedEngine.EffectsVolume = 1.0f; CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/pew-pew-lei"); splashPool.Position = monster.Position; AddChild(splashPool); var fade = new CCFadeOut(3.0f); var particleEmitter = new CCCallFuncND(StartExplosion, monster); var sequencia = new CCSequence(particleEmitter, fade); CCSimpleAudioEngine.SharedEngine.EffectsVolume = 0.7f; CCSimpleAudioEngine.SharedEngine.PlayEffect("Sounds/SplatEffect"); splashPool.RunAction(sequencia); } break; } } foreach(var monster in monstersToDelete) { monster.StopAllActions(); _monstersOnScreen.Remove(monster); RemoveChild(monster); } }
public override void RunActionsInSprite(CCSprite sprite) { sprite.RunAction( new CCRepeatForever( new CCSequence( new CCMoveBy(0.05f, new CCPoint(10, 10)), new CCMoveBy(0.05f, new CCPoint(-10, -10))) ) ); CCMoveBy action = new CCMoveBy(2.0f, new CCPoint(400, 0)); CCMoveBy action_back = (CCMoveBy) action.Reverse(); sprite.RunAction( new CCRepeatForever( new CCSequence(action, action_back) )); }
public void renderScreenShot() { var size = Layer.VisibleBoundsWorldspace.Size; var texture = new CCRenderTexture(size,size); //var texture = new CCRenderTexture(512, 512); texture.AnchorPoint = new CCPoint(0, 0); texture.Begin(); Visit(); texture.End(); CCSprite sprite = new CCSprite(texture.Sprite.Texture); //sprite.Position = new CCPoint(256, 256); sprite.Position = new CCPoint(size.Width/2, size.Height / 2); sprite.Opacity = 182; //sprite.IsFlipY = true; AddChild(sprite, 999999); sprite.Color = CCColor3B.Green; sprite.RunAction( new CCSequence( new CCFadeTo (2, 0), new CCHide() ) ); }
public override void OnEnter() { base.OnEnter(); CenterSprites(0); var spr = new CCSprite("Images/grossini"); spr.Position = new CCPoint(100, 100); AddChild(spr); spr.RunAction(actF); }
public override void OnEnter() { base.OnEnter(); CenterSprites(0); var spr = new CCSprite("Images/grossini"); spr.Position = new CCPoint(200, 200); AddChild(spr); var act1 = new CCMoveBy (2, new CCPoint(0, 100)); var act2 = new CCCallFunc(Log1); var act3 = new CCMoveBy (2, new CCPoint(0, -100)); var act4 = new CCCallFunc(Log2); var act5 = new CCMoveBy (2, new CCPoint(100, -100)); var act6 = new CCCallFunc(Log3); var act7 = new CCMoveBy (2, new CCPoint(-100, 0)); var act8 = new CCCallFunc(Log4); var actF = new CCSequence(act1, act2, act3, act4, act5, act6, act7, act8); spr.RunAction(actF); }
public override void RunActionsInSprite(CCSprite sprite) { sprite.RunAction( new CCRepeatForever( new CCSequence( new CCMoveBy(0.05f, new CCPoint(10, 2)), new CCMoveBy(0.05f, new CCPoint(-10, -2))))); CCJumpBy jump = new CCJumpBy(2.0f, new CCPoint(400, 0), 100, 5); CCJumpBy jump_back = (CCJumpBy) jump.Reverse(); sprite.RunAction( new CCRepeatForever( new CCSequence(jump, jump_back) )); }
public override void RunActionsInSprite(CCSprite sprite) { CCSize s = Layer.VisibleBoundsWorldspace.Size; // sprite 1 CCBezierConfig bezier; bezier.ControlPoint1 = new CCPoint(0, s.Height / 2); bezier.ControlPoint2 = new CCPoint(300, -s.Height / 2); bezier.EndPosition = new CCPoint(300, 100); CCBezierBy bezierForward = new CCBezierBy(3, bezier); CCBezierBy bezierBack = (CCBezierBy) bezierForward.Reverse(); CCSequence seq = new CCSequence(bezierForward, bezierBack); CCRepeatForever rep = new CCRepeatForever(seq); sprite.RunAction(rep); sprite.RunAction( new CCRepeatForever( new CCSequence( new CCMoveBy(0.05f, new CCPoint(10, 0)), new CCMoveBy(0.05f, new CCPoint(-10, 0)) ) ) ); }