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); }
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 LabelTTFA8Test() { var layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255)); AddChild(layer, -10); // CCLabelBMFont label1 = new CCLabelTtf("Testing A8 Format", "MarkerFelt", 38); AddChild(label1); label1.Color = CCColor3B.Red; var fadeOut = new CCFadeOut (2); var fadeIn = new CCFadeIn (2); label1.RepeatForever(fadeIn, fadeOut); }
public Atlas4() { m_time = 0; // Upper Label label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); AddChild(label); label.AnchorPoint = CCPoint.AnchorMiddle; var BChar = (CCSprite)label[0]; var FChar = (CCSprite)label[7]; var AChar = (CCSprite)label[12]; var rotate = new CCRotateBy (2, 360); var rot_4ever = new CCRepeatForever (rotate); var scale = new CCScaleBy(2, 1.5f); var scale_back = scale.Reverse(); var scale_seq = new CCSequence(scale, scale_back); var scale_4ever = new CCRepeatForever (scale_seq); var jump = new CCJumpBy (0.5f, new CCPoint(), 60, 1); var jump_4ever = new CCRepeatForever (jump); var fade_out = new CCFadeOut (1); var fade_in = new CCFadeIn (1); var seq = new CCSequence(fade_out, fade_in); var fade_4ever = new CCRepeatForever (seq); BChar.RunAction(rot_4ever); BChar.RunAction(scale_4ever); FChar.RunAction(jump_4ever); AChar.RunAction(fade_4ever); // Bottom Label label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt"); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); var lastChar = (CCSprite)label2[3]; lastChar.RunAction(rot_4ever); //schedule( schedule_selector(Atlas4::step), 0.1f); base.Schedule(step, 0.1f); }
public LabelSystemFontColorAndOpacity() { m_time = 0; Color = new CCColor3B(128, 128, 128); Opacity = 255; label1 = new CCLabel("Label FadeOut/FadeIn", "fonts/Marker Felt.ttf", 40, CCLabelFormat.SystemFont) { Color = CCColor3B.Orange, // testing anchors AnchorPoint = CCPoint.AnchorLowerLeft }; AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); var fade = new CCFadeOut (1.0f); var fade_in = fade.Reverse(); label1.RepeatForever ( fade, fade_in); label2 = new CCLabel("Label TintTo", "fonts/MorrisRoman-Black.ttf", 40, CCLabelFormat.SystemFont) { Color = CCColor3B.Red, // testing anchors AnchorPoint = CCPoint.AnchorMiddle }; AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.RepeatForever( new CCTintTo (1, 255, 0, 0), new CCTintTo (1, 0, 255, 0), new CCTintTo (1, 0, 0, 255)); label3 = new CCLabel("Label\nPlain\nBlue", "Helvetica", 40, CCLabelFormat.SystemFont) { Color = CCColor3B.Blue, Opacity = 128, // testing anchors AnchorPoint = CCPoint.AnchorUpperRight }; AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); //base.Schedule(step); }
public LabelAtlasColorTest() { CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label1, 0, (int)TagSprite.kTagSprite1); label1.Position = new CCPoint(10, 100); label1.Opacity = 200; CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label2, 0, (int)TagSprite.kTagSprite2); label2.Position = new CCPoint(10, 200); label2.Color = ccRED; CCFiniteTimeAction fade = new CCFadeOut (1.0f); CCFiniteTimeAction fade_in = fade.Reverse(); CCFiniteTimeAction seq = new CCSequence(fade, fade_in); CCAction repeat = new CCRepeatForever ((CCFiniteTimeAction)seq); label2.RunAction(repeat); m_time = 0; Schedule(step); //:@selector(step:)]; }
public LabelFNTColorAndOpacity() { m_time = 0; Color = new CCColor3B(128, 128, 128); Opacity = 255; label1 = new CCLabel("Label1", "fonts/bitmapFontTest2.fnt"); // testing anchors label1.AnchorPoint = CCPoint.AnchorLowerLeft; AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); var fade = new CCFadeOut (1.0f); var fade_in = fade.Reverse(); label1.RepeatForever ( fade, fade_in); // VERY IMPORTANT // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image) // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected label2 = new CCLabel("Label2", "fonts/bitmapFontTest2.fnt"); // testing anchors label2.AnchorPoint = CCPoint.AnchorMiddle; label2.Color = CCColor3B.Red; AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.RepeatForever( new CCTintTo (1, 255, 0, 0), new CCTintTo (1, 0, 255, 0), new CCTintTo (1, 0, 0, 255)); label3 = new CCLabel("Label3", "fonts/bitmapFontTest2.fnt"); // testing anchors label3.AnchorPoint = CCPoint.AnchorUpperRight; AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); base.Schedule(step); }
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 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 ActionFade() { action1 = new CCFadeIn(1.0f); action1Back = action1.Reverse(); action2 = new CCFadeOut(1.0f); action2Back = action2.Reverse(); }
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); } }
void AddNewSprite() { CCSize s = Layer.VisibleBoundsWorldspace.Size; CCPoint p = new CCPoint((float)(CCRandom.NextDouble() * s.Width), (float)(CCRandom.NextDouble() * s.Height)); int idx = (int)(CCRandom.NextDouble() * 1400 / 100); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCNode node = GetChildByTag((int)kTags.kTagSpriteBatchNode); CCSprite sprite = new CCSprite(texture1, new CCRect(x, y, 85, 121)); node.AddChild(sprite); sprite.Position = (new CCPoint(p.X, p.Y)); CCFiniteTimeAction action; 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 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; }
protected override void AddedToScene() { base.AddedToScene(); var visibleRect = VisibleBoundsWorldspace; loading.Position = visibleRect.Center; LoadLabel((fntFNT) => { label1 = new CCLabel(fntFNT, "Label1", CCSize.Zero, CCLabelFormat.BitMapFont); AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); //// testing anchors label1.AnchorPoint = CCPoint.AnchorLowerLeft; label1.Position = visibleRect.LeftBottom(); var fade = new CCFadeOut(1.0f); var fade_in = fade.Reverse(); label1.RepeatForever(fade, fade_in); // VERY IMPORTANT // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image) // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected label2 = new CCLabel(fntFNT, "Label2", CCSize.Zero, CCLabelFormat.BitMapFont); // testing anchors label2.AnchorPoint = CCPoint.AnchorMiddle; label2.Color = CCColor3B.Red; label2.Position = visibleRect.Center(); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.RepeatForever(new CCTintTo(1, 255, 0, 0), new CCTintTo(1, 0, 255, 0), new CCTintTo(1, 0, 0, 255)); label3 = new CCLabel(fntFNT, "Label3", CCSize.Zero, CCLabelFormat.BitMapFont); // testing anchors label3.AnchorPoint = CCPoint.AnchorUpperRight; label3.Position = visibleRect.RightTop(); AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); loading.Visible = false; } ); }