public void UpdateSpriteSize(int index, int edit) { ScheduleOnce((dt) => { if (index != -1 && edit != EditTypes.None) { if (edit == EditTypes.UpdateSizeUp) { var mIconRef = iconList2[index]; var mSprite = mIconRef.Sprite; var action = new CCScaleBy(0.5f, 1.1f); mSprite.AddAction(action); } else if (edit == EditTypes.UpdateSizeDown) { var mIconRef = iconList2[index]; var mSprite = mIconRef.Sprite; var action = new CCScaleBy(0.5f, 0.9f); mSprite.AddAction(action); } else if (edit == EditTypes.UpdateSizeDefault) { var mIconRef = iconList2[index]; var mSprite = mIconRef.Sprite; var action = new CCScaleTo(0.5f, 1f); mSprite.AddAction(action); } } }, 0); }
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 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 override void Update(float dt) { elapsed += dt; if (elapsed > 1f) { elapsed = 0f; // CCLabelBMFont if (label1 != null) { RemoveChild(label1); } CCNode node = new CCNode(); CCSize s = CCDirector.SharedDirector.WinSize; float x = s.Width * CCMacros.CCRandomBetween0And1(); float y = s.Height * CCMacros.CCRandomBetween0And1(); label1 = new CCLabelBMFont(string.Format("{0:N2},{1:N2} @ Mem Leak Ctor", x, y), "fonts/konqa32.fnt", 255f, CCTextAlignment.Right, CCPoint.Zero); node.AddChild(label1); label1.Position = new CCPoint(x, y); AddChild(node); label1 = node; // Start - test case for memory leak mentioned at https://cocos2dxna.codeplex.com/discussions/544032 node.Scale = 2f; //--> This action causes the leak CCScaleTo acScale = new CCScaleTo(0.1f, 1); CCDelayTime acShow = new CCDelayTime(0.1f); CCSplitRows acFadeOut = new CCSplitRows(0.1f, 20); CCRemoveSelf acRemove = new CCRemoveSelf(true); CCSequence seq = new CCSequence(acScale, acShow, acFadeOut, acRemove); node.RunAction(seq); } }
private void HandleTouchEnded(List <CCTouch> touches, CCEvent touchEvent) { if (!touchEvent.CurrentTarget.BoundingBoxTransformedToParent.ContainsPoint(touches[0].Location)) { return; } PauseListeners(true); var cardSprite = ChosenCard.CardSprite = new CCSprite(ChosenCard.ImageName); cardSprite.ContentSize = new CCSize(_cardWidth, _cardHeight); cardSprite.Scale = .1f; cardSprite.Position = cardSprite.BoundingBox.UpperRight; cardSprite.UserObject = ChosenCard; touchEvent.CurrentTarget.AddChild(cardSprite, 1); var animateCardIn = new CCScaleTo(.5f, 1.0f); cardSprite.RunAction(animateCardIn); touchEvent.StopPropogation(); RemoveEventListener(_touchListeners[touchEvent.CurrentTarget.Tag]); FlipCards(touchEvent.CurrentTarget); ChangeTeams(); ScheduleOnce(GoToChooseCard, 4f); }
public void ScaleBalloon(float touchForce, float maxTouchForce) { if (gamePaused == false) { if (touchForce >= 1) { CCScaleTo scaleUpTo = new CCScaleTo(0.25f, 1 + float.Parse((touchForce / 3).ToString())); this.touchForce = touchForce; balloonSprite.RunActions(scaleUpTo, new CCCallFunc(() => { if (touchForce >= Math.Floor(double.Parse(maxTouchForce.ToString()))) { this.touchForce = -1; ExplodeBalloon(); } })); } else { CCScaleTo scaleDownTo = new CCScaleTo(0.25f, 1); balloonSprite.RunAction(scaleDownTo); } } }
void scaleButtonTo(float scale) { var action = new CCScaleTo(0.1f, scale); action.Tag = 900; StopAction(900); RunAction(action); }
/// <summary> /// creates the action with and X factor and a Y factor /// </summary> /// <param name="duration"></param> /// <param name="sx"></param> /// <param name="sy"></param> /// <returns></returns> public static CCScaleTo actionWithDuration(float duration, float sx, float sy) { CCScaleTo pScaleTo = new CCScaleTo(); pScaleTo.initWithDuration(duration, sx, sy); //pScaleTo->autorelease(); return pScaleTo; }
public TMXReadWriteTest() { m_gid = 0; CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/orthogonal-test2"); addChild(map, 0, TileMapTestScene.kTagTileMap); CCSize s = map.contentSize; ////----UXLOG("ContentSize: %f, %f", s.width,s.height); CCTMXLayer layer = map.layerNamed("Layer 0"); layer.Texture.setAntiAliasTexParameters(); map.scale = 1; CCSprite tile0 = layer.tileAt(new CCPoint(1, 63)); CCSprite tile1 = layer.tileAt(new CCPoint(2, 63)); CCSprite tile2 = layer.tileAt(new CCPoint(3, 62));//ccp(1,62)); CCSprite tile3 = layer.tileAt(new CCPoint(2, 62)); tile0.anchorPoint = new CCPoint(0.5f, 0.5f); tile1.anchorPoint = new CCPoint(0.5f, 0.5f); tile2.anchorPoint = new CCPoint(0.5f, 0.5f); tile3.anchorPoint = new CCPoint(0.5f, 0.5f); CCActionInterval move = CCMoveBy.actionWithDuration(0.5f, new CCPoint(0, 160)); CCActionInterval rotate = CCRotateBy.actionWithDuration(2, 360); CCActionInterval scale = CCScaleBy.actionWithDuration(2, 5); CCActionInterval opacity = CCFadeOut.actionWithDuration(2); CCActionInterval fadein = CCFadeIn.actionWithDuration(2); CCActionInterval scaleback = CCScaleTo.actionWithDuration(1, 1); CCActionInstant finish = CCCallFuncN.actionWithTarget(this, removeSprite); CCFiniteTimeAction seq0 = CCSequence.actions(move, rotate, scale, opacity, fadein, scaleback, finish); CCActionInterval seq1 = (CCActionInterval)(seq0.copy()); CCActionInterval seq2 = (CCActionInterval)(seq0.copy()); CCActionInterval seq3 = (CCActionInterval)(seq0.copy()); tile0.runAction(seq0); tile1.runAction(seq1); tile2.runAction(seq2); tile3.runAction(seq3); m_gid = layer.tileGIDAt(new CCPoint(0, 63)); ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid); schedule(updateCol, 2.0f); schedule(repaintWithGID, 2.0f); schedule(removeTiles, 1.0f); ////----UXLOG("++++atlas quantity: %d", layer->textureAtlas()->getTotalQuads()); ////----UXLOG("++++children: %d", layer->getChildren()->count() ); m_gid2 = 0; }
/// <summary> /// creates the action with the same scale factor for X and Y /// </summary> /// <param name="duration"></param> /// <param name="s"></param> /// <returns></returns> public static CCScaleTo actionWithDuration(float duration, float s) { CCScaleTo pScaleTo = new CCScaleTo(); pScaleTo.initWithDuration(duration, s); //pScaleTo->autorelease(); return(pScaleTo); }
public override void OnEnter() { base.OnEnter(); CCSize s = Layer.VisibleBoundsWorldspace.Size; var layer1 = new CCLayerColor(new CCColor4B(0xFF, 0xFF, 0x00, 0x80)); layer1.IgnoreAnchorPointForPosition = false; layer1.Position = (new CCPoint(s.Width / 2, s.Height / 2)); layer1.ChildClippingMode = CCClipMode.Bounds; AddChild(layer1, 1); s = layer1.ContentSize; m_pInnerLayer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80)); m_pInnerLayer.IgnoreAnchorPointForPosition = false; m_pInnerLayer.Position = (new CCPoint(s.Width / 2, s.Height / 2)); m_pInnerLayer.ChildClippingMode = CCClipMode.Bounds; layer1.AddChild(m_pInnerLayer, 1); // // Add two labels using BM label class // CCLabelBMFont CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt"); label1.Position = new CCPoint(m_pInnerLayer.ContentSize.Width, m_pInnerLayer.ContentSize.Height * 0.75f); m_pInnerLayer.AddChild(label1); CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt"); label2.Position = new CCPoint(0, m_pInnerLayer.ContentSize.Height * 0.25f); m_pInnerLayer.AddChild(label2); CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 3.0f); CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 1.0f); m_pInnerLayer.RepeatForever(scaleTo2, scaleTo3); CCFiniteTimeAction seq = new CCRepeatForever( new CCSequence(scaleTo2, scaleTo3) ); m_pInnerLayer.RunAction(seq); CCSize size = Layer.VisibleBoundsWorldspace.Size; var move1 = new CCMoveTo(2, new CCPoint(size.Width / 2, size.Height)); var move2 = new CCMoveTo(2, new CCPoint(size.Width, size.Height / 2)); var move3 = new CCMoveTo(2, new CCPoint(size.Width / 2, 0)); var move4 = new CCMoveTo(2, new CCPoint(0, size.Height / 2)); layer1.RunAction(new CCRepeatForever(new CCSequence(move1, move2, move3, move4))); }
public CCScaleToState (CCScaleTo action, CCNode target) : base (action, target) { StartScaleX = target.ScaleX; StartScaleY = target.ScaleY; EndScaleX = action.EndScaleX; EndScaleY = action.EndScaleY; DeltaX = EndScaleX - StartScaleX; DeltaY = EndScaleY - StartScaleY; }
public CCScaleToState(CCScaleTo action, CCNode target) : base(action, target) { StartScaleX = target.ScaleX; StartScaleY = target.ScaleY; EndScaleX = action.EndScaleX; EndScaleY = action.EndScaleY; DeltaX = EndScaleX - StartScaleX; DeltaY = EndScaleY - StartScaleY; }
protected override void AddedToScene() { base.AddedToScene(); var winSize = VisibleBoundsWorldspace.Size; 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 buttonNormal = new CCSprite("Images/animationbuttonnormal.png"); var button1 = new Button(buttonNormal, new CCLabel("Click", "fonts/arial", 20, CCLabelFormat.SpriteFont)); button1.Position = winSize.Center; button1.PositionX -= 100; button1.PositionY += 100; AddChild(button1); button1.RunAction(action); var button2 = new Button(buttonNormal, new CCLabel("Me", "fonts/arial", 20, CCLabelFormat.SpriteFont)); button2.Position = winSize.Center; button2.PositionX += 100; button2.PositionY += 100; AddChild(button2); button2.RunAction(action); var button3 = new Button(buttonNormal, new CCLabel("Ple", "fonts/arial", 20, CCLabelFormat.SpriteFont)); button3.Position = winSize.Center; button3.PositionX -= 100; button3.PositionY -= 100; AddChild(button3); button3.RunAction(action); var button4 = new Button(buttonNormal, new CCLabel("ase", "fonts/arial", 20, CCLabelFormat.SpriteFont)); button4.Position = winSize.Center; button4.PositionX += 100; button4.PositionY -= 100; AddChild(button4); button4.RunAction(action); }
public TMXReadWriteTest() { m_gid = 0; CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test2"); AddChild(map, 0, kTagTileMap); CCTMXLayer layer = map.LayerNamed("Layer 0"); layer.IsAntialiased = true; map.Scale = (1); CCSprite tile0 = layer.TileAt(new CCPoint(1, 63)); CCSprite tile1 = layer.TileAt(new CCPoint(2, 63)); CCSprite tile2 = layer.TileAt(new CCPoint(3, 62)); //new CCPoint(1,62)); CCSprite tile3 = layer.TileAt(new CCPoint(2, 62)); tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f)); tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f)); tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f)); tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f)); CCMoveBy move = new CCMoveBy(0.5f, new CCPoint(0, 160)); CCRotateBy rotate = new CCRotateBy(2, 360); CCScaleBy scale = new CCScaleBy(2, 5); CCFadeOut opacity = new CCFadeOut(2); CCFadeIn fadein = new CCFadeIn(2); CCScaleTo scaleback = new CCScaleTo(1, 1); CCCallFuncN finish = new CCCallFuncN(removeSprite); CCSequence sequence = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish); tile0.RunAction(sequence); tile1.RunAction(sequence); tile2.RunAction(sequence); tile3.RunAction(sequence); m_gid = layer.TileGIDAt(new CCPoint(0, 63)); ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid); Schedule(updateCol, 2.0f); Schedule(repaintWithGID, 2.0f); Schedule(removeTiles, 1.0f); ////----UXLOG("++++atlas quantity: %d", layer.textureAtlas().getTotalQuads()); ////----UXLOG("++++children: %d", layer.getChildren().count() ); m_gid2 = 0; }
void OnTouchesEnded(List <CCTouch> touches, CCEvent touchEvent) { if (touches.Count > 0) { } if (lastFrequencyKnobTouch != null) { lastFrequencyKnobTouch = null; lastFreqKnobTouchY = 0; lastFreqKnobTouchX = 0; var action = new CCScaleTo(0.1f, 1.0f); frequencyKnob.RunActions(action); } }
public override void onEnter() { base.onEnter(); centerSprites(3); CCActionInterval actionTo = CCScaleTo.actionWithDuration(2, 0.5f); CCActionInterval actionBy = CCScaleBy.actionWithDuration(2, 2); CCActionInterval actionBy2 = CCScaleBy.actionWithDuration(2, 0.25f, 4.5f); CCFiniteTimeAction actionByBack = actionBy.reverse(); m_tamara.runAction(actionTo); m_grossini.runAction(CCSequence.actions(actionBy, actionByBack)); m_kathia.runAction(CCSequence.actions(actionBy2, actionBy2.reverse())); }
public override void OnEnter() { base.OnEnter(); centerSprites(3); var actionTo = new CCScaleTo(2, 0.5f); var actionBy = new CCScaleBy(2, 1, 10); var actionBy2 = new CCScaleBy(2, 5f, 1.0f); var actionByBack = actionBy.Reverse(); m_grossini.RunAction(actionTo); m_tamara.RunAction(CCSequence.FromActions(actionBy, actionBy.Reverse())); m_kathia.RunAction(CCSequence.FromActions(actionBy2, actionBy2.Reverse())); }
public override void OnEnter() { base.OnEnter(); m_tamara.RemoveFromParentAndCleanup(true); m_grossini.RemoveFromParentAndCleanup(true); m_kathia.RemoveFromParentAndCleanup(true); // Get window size so that we can center the box layer var winSize = CCDirector.SharedDirector.WinSize; var boxSize = new CCSize(100.0f, 100.0f); var box = new CCLayerColor(new CCColor4B(255, 255, 0, 255)); box.AnchorPoint = new CCPoint(0, 0); box.Position = new CCPoint(winSize.Center.X - (boxSize.Width / 2), winSize.Center.Y - (boxSize.Height / 2)); box.ContentSize = boxSize; var uL = new CCLayerColor(new CCColor4B(255, 0, 0, 255)); box.AddChild(uL); uL.ContentSize = new CCSize(markrside, markrside); uL.Position = new CCPoint(0.0f, boxSize.Height - markrside); uL.AnchorPoint = new CCPoint(0, 0); var uR = new CCLayerColor(new CCColor4B(0, 0, 255, 255)); box.AddChild(uR); uR.ContentSize = new CCSize(markrside, markrside); uR.Position = new CCPoint(boxSize.Width - markrside, boxSize.Height - markrside); uR.AnchorPoint = new CCPoint(0, 0); AddChild(box); var actionTo = new CCSkewTo(2, 0.0f, 2.0f); var rotateTo = new CCRotateTo(2, 61.0f); var actionScaleTo = new CCScaleTo(2, -0.44f, 0.47f); var actionScaleToBack = new CCScaleTo(2, 1.0f, 1.0f); var rotateToBack = new CCRotateTo(2, 0); var actionToBack = new CCSkewTo(2, 0, 0); box.RunAction(CCSequence.FromActions(actionTo, actionToBack)); box.RunAction(CCSequence.FromActions(rotateTo, rotateToBack)); box.RunAction(CCSequence.FromActions(actionScaleTo, actionScaleToBack)); }
public override void onEnter() { // todo: CCLayerColor hasn't been implemented base.onEnter(); m_tamara.removeFromParentAndCleanup(true); m_grossini.removeFromParentAndCleanup(true); m_kathia.removeFromParentAndCleanup(true); CCSize boxSize = new CCSize(100.0f, 100.0f); CCLayerColor box = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 0, 255)); box.anchorPoint = new CCPoint(0, 0); box.position = new CCPoint(190, 110); box.contentSize = boxSize; CCLayerColor uL = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 0, 255)); box.addChild(uL); uL.contentSize = new CCSize(markrside, markrside); uL.position = new CCPoint(0.0f, boxSize.height - markrside); uL.anchorPoint = new CCPoint(0, 0); CCLayerColor uR = CCLayerColor.layerWithColor(new ccColor4B(0, 0, 255, 255)); box.addChild(uR); uR.contentSize = new CCSize(markrside, markrside); uR.position = new CCPoint(boxSize.width - markrside, boxSize.height - markrside); uR.anchorPoint = new CCPoint(0, 0); addChild(box); CCActionInterval actionTo = CCSkewTo.actionWithDuration(2, 0.0f, 2.0f); CCActionInterval rotateTo = CCRotateTo.actionWithDuration(2, 61.0f); CCActionInterval actionScaleTo = CCScaleTo.actionWithDuration(2, -0.44f, 0.47f); CCActionInterval actionScaleToBack = CCScaleTo.actionWithDuration(2, 1.0f, 1.0f); CCActionInterval rotateToBack = CCRotateTo.actionWithDuration(2, 0); CCActionInterval actionToBack = CCSkewTo.actionWithDuration(2, 0, 0); box.runAction(CCSequence.actions(actionTo, actionToBack)); box.runAction(CCSequence.actions(rotateTo, rotateToBack)); box.runAction(CCSequence.actions(actionScaleTo, actionScaleToBack)); }
private void OnTouchesBegan(List <CCTouch> ccTouches, CCEvent ccEvent) { foreach (CCTouch touch in ccTouches) { if (touch != null) { CCPoint tap = touch.Location; if (frequencyKnob.BoundingBox.ContainsPoint(tap)) { lastFrequencyKnobTouch = touch; lastFreqKnobTouchY = (int)lastFrequencyKnobTouch.Location.Y; lastFreqKnobTouchX = (int)lastFrequencyKnobTouch.Location.X; var action = new CCScaleTo(0.1f, 0.9f); frequencyKnob.RunActions(action); } } } }
public TMXReadWriteTest() : base("TileMaps/orthogonal-test2") { m_gid = CCTileGidAndFlags.EmptyTile; CCTileMapLayer layer = tileMap.LayerNamed("Layer 0"); layer.Antialiased = true; tileMap.Scale = (1); CCSprite tile0 = layer.ExtractTile(1, 63); CCSprite tile1 = layer.ExtractTile(2, 63); CCSprite tile2 = layer.ExtractTile(3, 62); //new CCPoint(1,62)); CCSprite tile3 = layer.ExtractTile(2, 62); tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f)); tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f)); tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f)); tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f)); CCMoveBy move = new CCMoveBy(0.5f, new CCPoint(0, 160)); CCRotateBy rotate = new CCRotateBy(2, 360); CCScaleBy scale = new CCScaleBy(2, 5); CCFadeOut opacity = new CCFadeOut(2); CCFadeIn fadein = new CCFadeIn(2); CCScaleTo scaleback = new CCScaleTo(1, 1); CCCallFuncN finish = new CCCallFuncN(removeSprite); CCSequence sequence = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish); tile0.RunAction(sequence); tile1.RunAction(sequence); tile2.RunAction(sequence); tile3.RunAction(sequence); m_gid = layer.TileGIDAndFlags(0, 63); Schedule(updateCol, 2.0f); Schedule(repaintWithGID, 2.0f); Schedule(removeTiles, 1.0f); m_gid2 = CCTileGidAndFlags.EmptyTile; }
public override void onEnter() { base.onEnter(); this.isTouchEnabled = true; CCSize s = CCDirector.sharedDirector().getWinSize(); CCLayerColor layer = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0xFF, 0x00, 0x00, 0x80), s.width * 0.75f, s.height * 0.75f); layer.isRelativeAnchorPoint = true; layer.position = (new CCPoint(s.width / 2, s.height / 2)); addChild(layer, 1, kTagLayer); // // Add two labels using BM label class // CCLabelBMFont CCLabelBMFont label1 = CCLabelBMFont.labelWithString("LABEL1", "fonts/fnt/konqa32"); layer.addChild(label1); label1.position = new CCPoint(layer.contentSize.width / 2, layer.contentSize.height * 0.75f); CCLabelBMFont label2 = CCLabelBMFont.labelWithString("LABEL2", "fonts/fnt/konqa32"); layer.addChild(label2); label2.position = new CCPoint(layer.contentSize.width / 2, layer.contentSize.height * 0.25f); // // Do the sequence of actions in the bug report float waitTime = 3f; float runTime = 12f; layer.visible = false; CCHide hide = CCHide.action(); CCScaleTo scaleTo1 = CCScaleTo.actionWithDuration(0.0f, 0.0f); CCShow show = CCShow.action(); CCDelayTime delay = CCDelayTime.actionWithDuration(waitTime); CCScaleTo scaleTo2 = CCScaleTo.actionWithDuration(runTime * 0.25f, 1.2f); CCScaleTo scaleTo3 = CCScaleTo.actionWithDuration(runTime * 0.25f, 0.95f); CCScaleTo scaleTo4 = CCScaleTo.actionWithDuration(runTime * 0.25f, 1.1f); CCScaleTo scaleTo5 = CCScaleTo.actionWithDuration(runTime * 0.25f, 1.0f); CCFiniteTimeAction seq = CCSequence.actions(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5); layer.runAction(seq); }
public override void OnEnter() { base.OnEnter(); this.TouchEnabled = true; CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f); layer.IgnoreAnchorPointForPosition = false; layer.Position = (new CCPoint(s.Width / 2, s.Height / 2)); AddChild(layer, 1, kTagLayer); // // Add two labels using BM label class // CCLabelBMFont CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt"); layer.AddChild(label1); label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f); CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt"); layer.AddChild(label2); label2.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.25f); // // Do the sequence of actions in the bug report float waitTime = 3f; float runTime = 12f; layer.Visible = false; CCHide hide = new CCHide(); CCScaleTo scaleTo1 = new CCScaleTo(0.0f, 0.0f); CCShow show = new CCShow(); CCDelayTime delay = new CCDelayTime(waitTime); CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 1.2f); CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 0.95f); CCScaleTo scaleTo4 = new CCScaleTo(runTime * 0.25f, 1.1f); CCScaleTo scaleTo5 = new CCScaleTo(runTime * 0.25f, 1.0f); CCFiniteTimeAction seq = CCSequence.FromActions(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5); layer.RunAction(seq); }
protected override void AddedToScene() { base.AddedToScene(); var bounds = VisibleBoundsWorldspace; var action = new CCScaleTo(1.0f, 1.0f); titleLabel.Position = new CCPoint(bounds.Center.X, 50); menu.Position = new CCPoint(bounds.Center.X, bounds.MaxY - 100); onOffSwitch.Scale = 0.1f; onOffSwitch.RunActions(action); frequencyLabel.Position = new CCPoint(bounds.Center.X, bounds.Center.Y + 120); frequencyKnob.Scale = 0.0f; frequencyKnob.Position = bounds.Center; frequencyKnob.AnchorPoint = new CCPoint(0.5f, 0.5f); frequencyKnob.RunActions(action); var touchListener = new CCEventListenerTouchAllAtOnce(); touchListener.OnTouchesBegan = OnTouchesBegan; touchListener.OnTouchesMoved = OnTouchesMoved; touchListener.OnTouchesEnded = OnTouchesEnded; AddEventListener(touchListener, this); UpdateFrequency(frequency); var appDelegate = Application.ApplicationDelegate as AppDelegate; if (appDelegate != null && appDelegate.BackButtonWasPressed != null) { Schedule((dt) => { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { appDelegate.BackButtonWasPressed(); } }); } }
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); }
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 override CCObject copyWithZone(CCZone pZone) { CCZone pNewZone = null; CCScaleTo pCopy = null; if (pZone != null && pZone.m_pCopyObject != null) { //in case of being called at sub class pCopy = (CCScaleTo)(pZone.m_pCopyObject); } else { pCopy = new CCScaleTo(); pZone = pNewZone = new CCZone(pCopy); } base.copyWithZone(pZone); pCopy.initWithDuration(Duration, m_fEndScaleX, m_fEndScaleY); //CC_SAFE_DELETE(pNewZone); return pCopy; }
/// <summary> /// Запускает анимацию перед переходом на другой экран /// </summary> private void RunOutroAnimations() { var scale = new CCScaleTo(0.5f, 0.05f); var fadeOut = new CCFadeOut(0.5f); _logo.RunAction(new CCSequence(scale, new CCCallFunc(NavigateToNextScene))); _logo.RunAction(fadeOut); foreach (var item in _buttonsMenu.Children) { var scaleCopy = scale.Copy(); var fadeOutCopy = fadeOut.Copy(); item.RunAction(scaleCopy); item.RunAction(fadeOutCopy); } var gems = _fallingGems.Keys.ToArray(); for (int i = 0; i < gems.Length; i++) { var gem = gems[i]; var fade = new CCFadeOut(0.5f); gem.RunAction(fade); } }
public override CCObject copyWithZone(CCZone pZone) { CCZone pNewZone = null; CCScaleTo pCopy = null; if (pZone != null && pZone.m_pCopyObject != null) { //in case of being called at sub class pCopy = (CCScaleBy)(pZone.m_pCopyObject); } else { pCopy = new CCScaleBy(); pZone = pNewZone = new CCZone(pCopy); } base.copyWithZone(pZone); pCopy.initWithDuration(Duration, m_fEndScaleX, m_fEndScaleY); //CC_SAFE_DELETE(pNewZone); return(pCopy); }
protected override void Step(float dt) { base.Step (dt); if (gameSuspended) return; var batchnode = GetChild((int)Tags.SpriteManager) as CCSpriteBatchNode; var bird = batchnode.GetChild((int)Tags.Bird) as CCSprite; var particles = GetChild((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.GetChild((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 = GetChild((int)Tags.ScoreLabel) as CCLabelBMFont; scorelabel.Label = score.ToString(); var a1 = new CCScaleTo(.2f,1.5f,.08f); var a2 = new CCScaleTo(.2f,1f,1f); var a3 = CCSequence.FromActions(new CCFiniteTimeAction[] {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.GetChild(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.GetChild(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.GetChild(t) as CCSprite; var pos = platform.Position; pos = new PointF(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 = GetChild((int)Tags.ScoreLabel) as CCLabelBMFont; scoreLabel.Label = score.ToString(); } bird.Position = bird_pos; if (particles !=null) { var particle_pos = new PointF(bird_pos.X,bird_pos.Y-17); particles.Position = particle_pos; } }
protected CCScaleTo(CCScaleTo copy) : base(copy) { m_fEndScaleX = copy.m_fEndScaleX; m_fEndScaleY = copy.m_fEndScaleY; }
protected override void Step(float dt) { base.Step(dt); if (gameSuspended) { return; } var batchnode = GetChild((int)Tags.SpriteManager) as CCSpriteBatchNode; var bird = batchnode.GetChild((int)Tags.Bird) as CCSprite; var particles = GetChild((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; nfloat max_x = 320 - bird_size.Width / 2; nfloat 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.GetChild((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 = GetChild((int)Tags.ScoreLabel) as CCLabelBMFont; scorelabel.Label = score.ToString(); var a1 = new CCScaleTo(.2f, 1.5f, .08f); var a2 = new CCScaleTo(.2f, 1f, 1f); var a3 = CCSequence.FromActions(new CCFiniteTimeAction[] { 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.GetChild(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; nfloat 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) { nfloat 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.GetChild(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.GetChild(t) as CCSprite; var pos = platform.Position; pos = new CGPoint(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(); } else { bonus.Position = pos; } } score += (int)delta; var scoreLabel = GetChild((int)Tags.ScoreLabel) as CCLabelBMFont; scoreLabel.Label = score.ToString(); } bird.Position = bird_pos; if (particles != null) { var particle_pos = new CGPoint(bird_pos.X, bird_pos.Y - 17); particles.Position = particle_pos; } }
private void SetupShimmer() { CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("GameScene/shimmer.plist"); for (var i = 0; i < 2; i++) { var sprt = new CCSprite("shimmergamescene/shimmer/bg-shimmer-" + i + ".png"); CCActionInterval seqRot = null; CCActionInterval seqMov = null; CCActionInterval seqSca = null; float x; float y; float rot; for (var j = 0; j < 10; j++) { var time = (float)(CCRandom.NextDouble() * 10 + 5); x = Constants.KBoardWidth * Constants.KGemSize / 2; y = (float)(CCRandom.NextDouble() * Constants.KBoardHeight * Constants.KGemSize); rot = (float)(CCRandom.NextDouble() * 180 - 90); var scale = (float)(CCRandom.NextDouble() * 3 + 3); var actionRot = new CCEaseInOut(new CCRotateTo(time, rot), 2); var actionMov = new CCEaseInOut(new CCMoveTo(time, new CCPoint(x, y)), 2); var actionSca = new CCScaleTo(time, scale); if (seqRot == null) { seqRot = actionRot; seqMov = actionMov; seqSca = actionSca; } else { seqRot = new CCSequence(seqRot, actionRot); seqMov = new CCSequence(seqMov, actionMov); seqSca = new CCSequence(seqSca, actionSca); } } x = _fieldPositionZero.X + Constants.KBoardWidth * Constants.KGemSize / 2; y = _fieldPositionZero.Y + (float)CCRandom.NextDouble() * Constants.KBoardHeight * Constants.KGemSize; rot = (float)CCRandom.NextDouble() * 180 - 90; sprt.Position = new CCPoint(x, y); sprt.Rotation = rot; sprt.Position = new CCPoint(_fieldPositionZero.X + Constants.KBoardWidth * Constants.KGemSize / 2, _fieldPositionZero.Y + Constants.KBoardHeight * Constants.KGemSize / 2); sprt.BlendFunc = new CCBlendFunc(CCOGLES.GL_SRC_ALPHA, CCOGLES.GL_ONE); sprt.Scale = 3; _shimmerLayer.AddChild(sprt); sprt.Opacity = 0; sprt.RunAction(new CCRepeatForever(seqRot)); sprt.RunAction(new CCRepeatForever(seqMov)); sprt.RunAction(new CCRepeatForever(seqSca)); sprt.RunAction(new CCFadeIn(2)); } }
void HandleMoveCircle(CCTouch touch) { const float timeToTake = 1.5f; // in seconds CCFiniteTimeAction coreAction = null; // By default all actions will be added directly to the // root node - it has values for Position, Scale, and Rotation. CCNode nodeToAddTo = drawNodeRoot; switch (VariableOptions [currentVariableIndex]) { case "Position": coreAction = new CCMoveTo(timeToTake, touch.Location); break; case "Scale": var distance = CCPoint.Distance(touch.Location, drawNodeRoot.Position); var desiredScale = distance / DefaultCircleRadius; coreAction = new CCScaleTo(timeToTake, desiredScale); break; case "Rotation": float differenceY = touch.Location.Y - drawNodeRoot.PositionY; float differenceX = touch.Location.X - drawNodeRoot.PositionX; float angleInDegrees = -1 * CCMathHelper.ToDegrees( (float)Math.Atan2(differenceY, differenceX)); coreAction = new CCRotateTo(timeToTake, angleInDegrees); break; case "LineWidth": coreAction = new LineWidthAction(timeToTake, touch.Location.X / 40f); // The LineWidthAction is a special action designed to work only on // LineNode instances, so we have to set the nodeToAddTo to the lineNode: nodeToAddTo = lineNode; break; } CCAction easing = null; switch (EasingOptions [currentEasingIndex]) { case "CCEaseBack": if (currentInOutIndex == 0) { easing = new CCEaseBackOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseBackIn(coreAction); } else { easing = new CCEaseBackInOut(coreAction); } break; case "CCEaseBounce": if (currentInOutIndex == 0) { easing = new CCEaseBounceOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseBounceIn(coreAction); } else { easing = new CCEaseBounceInOut(coreAction); } break; case "CCEaseElastic": if (currentInOutIndex == 0) { easing = new CCEaseElasticOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseElasticIn(coreAction); } else { easing = new CCEaseElasticInOut(coreAction); } break; case "CCEaseExponential": if (currentInOutIndex == 0) { easing = new CCEaseExponentialOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseExponentialIn(coreAction); } else { easing = new CCEaseExponentialInOut(coreAction); } break; case "CCEaseSine": if (currentInOutIndex == 0) { easing = new CCEaseSineOut(coreAction); } else if (currentInOutIndex == 1) { easing = new CCEaseSineIn(coreAction); } else { easing = new CCEaseSineInOut(coreAction); } break; } nodeToAddTo.AddAction(easing ?? coreAction); }
public CCScaleByState (CCScaleTo action, CCNode target) : base (action, target) { DeltaX = StartScaleX * EndScaleX - StartScaleX; DeltaY = StartScaleY * EndScaleY - StartScaleY; }
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); }