public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor layer1 = new CCLayerColor(new CCColor4B(255, 255, 0, 80), 100, 300); layer1.Position = (new CCPoint(s.Width / 3, s.Height / 2)); layer1.IgnoreAnchorPointForPosition = false; AddChild(layer1, 1); CCLayerColor layer2 = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 100, 300); layer2.Position = (new CCPoint((s.Width / 3) * 2, s.Height / 2)); layer2.IgnoreAnchorPointForPosition = false; AddChild(layer2, 1); CCActionInterval actionTint = new CCTintBy (2, -255, -127, 0); CCActionInterval actionTintBack = (CCActionInterval)actionTint.Reverse(); CCActionInterval seq1 = (CCActionInterval)CCSequence.FromActions(actionTint, actionTintBack); layer1.RunAction(seq1); CCActionInterval actionFade = new CCFadeOut (2.0f); CCActionInterval actionFadeBack = (CCActionInterval)actionFade.Reverse(); CCActionInterval seq2 = (CCActionInterval)CCSequence.FromActions(actionFade, actionFadeBack); layer2.RunAction(seq2); }
public 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)); BatchNode.AddChild(sprite); sprite.Position = (new CCPoint(p.X, p.Y)); CCActionInterval 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); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCActionInterval seq = (CCActionInterval)(new CCSequence(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
public 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; CCActionInterval 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(); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCActionInterval seq = (CCActionInterval)(new CCSequence(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
public LabelAtlasColorTest() { CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap.png", 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.png", 48, 64, ' '); AddChild(label2, 0, (int)TagSprite.kTagSprite2); label2.Position = new CCPoint(10, 200); //label2.setColor( ccRED ); label2.Color = ccRED; CCActionInterval fade = new CCFadeOut(1.0f); //CCActionInterval fade_in = fade.reverse(); CCActionInterval fade_in = null; CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in, null); CCAction repeat = new CCRepeatForever((CCActionInterval)seq); label2.RunAction(repeat); m_time = 0; //schedule( schedule_selector(LabelAtlasColorTest.step) ); //:@selector(step:)]; }
public Atlas4() { m_time = 0; // Upper Label CCLabelBMFont label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); AddChild(label); CCSize s = CCDirector.SharedDirector.WinSize; label.Position = new CCPoint(s.Width / 2, s.Height / 2); label.AnchorPoint = new CCPoint(0.5f, 0.5f); CCSprite BChar = (CCSprite)label.GetChildByTag(1); CCSprite FChar = (CCSprite)label.GetChildByTag(7); CCSprite AChar = (CCSprite)label.GetChildByTag(12); CCActionInterval rotate = new CCRotateBy(2, 360); CCAction rot_4ever = new CCRepeatForever(rotate); CCActionInterval scale = new CCScaleBy(2, 1.5f); //CCActionInterval scale_back = scale.reverse(); CCActionInterval scale_back = null; CCFiniteTimeAction scale_seq = CCSequence.FromActions(scale, scale_back, null); CCAction scale_4ever = new CCRepeatForever((CCActionInterval)scale_seq); CCActionInterval jump = new CCJumpBy(0.5f, new CCPoint(), 60, 1); CCAction jump_4ever = new CCRepeatForever(jump); CCActionInterval fade_out = new CCFadeOut(1); CCActionInterval fade_in = new CCFadeIn(1); CCFiniteTimeAction seq = CCSequence.FromActions(fade_out, fade_in, null); CCAction fade_4ever = new CCRepeatForever((CCActionInterval)seq); BChar.RunAction(rot_4ever); BChar.RunAction(scale_4ever); FChar.RunAction(jump_4ever); AChar.RunAction(fade_4ever); // Bottom Label CCLabelBMFont label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt"); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.Position = new CCPoint(s.Width / 2.0f, 80); CCSprite lastChar = (CCSprite)label2.GetChildByTag(3); lastChar.RunAction((CCAction)(rot_4ever.Copy())); //schedule( schedule_selector(Atlas4::step), 0.1f); base.Schedule(step, 0.1f); }
public Atlas4() { m_time = 0; // Upper Label CCLabelBMFont label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); AddChild(label); CCSize s = CCDirector.SharedDirector.WinSize; label.Position = new CCPoint(s.Width / 2, s.Height / 2); label.AnchorPoint = new CCPoint(0.5f, 0.5f); CCSprite BChar = (CCSprite)label.GetChildByTag(0); CCSprite FChar = (CCSprite)label.GetChildByTag(7); CCSprite AChar = (CCSprite)label.GetChildByTag(12); CCActionInterval rotate = new CCRotateBy (2, 360); CCAction rot_4ever = new CCRepeatForever (rotate); CCActionInterval scale = new CCScaleBy(2, 1.5f); CCFiniteTimeAction scale_back = scale.Reverse(); CCFiniteTimeAction scale_seq = new CCSequence(scale, scale_back); CCAction scale_4ever = new CCRepeatForever ((CCActionInterval)scale_seq); CCActionInterval jump = new CCJumpBy (0.5f, new CCPoint(), 60, 1); CCAction jump_4ever = new CCRepeatForever (jump); CCActionInterval fade_out = new CCFadeOut (1); CCActionInterval fade_in = new CCFadeIn (1); CCFiniteTimeAction seq = new CCSequence(fade_out, fade_in); CCAction fade_4ever = new CCRepeatForever ((CCActionInterval)seq); BChar.RunAction(rot_4ever); BChar.RunAction(scale_4ever); FChar.RunAction(jump_4ever); AChar.RunAction(fade_4ever); // Bottom Label CCLabelBMFont label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt"); AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.Position = new CCPoint(s.Width / 2.0f, 80); CCSprite lastChar = (CCSprite)label2.GetChildByTag(3); lastChar.RunAction((CCAction)(rot_4ever.Copy())); //schedule( schedule_selector(Atlas4::step), 0.1f); base.Schedule(step, 0.1f); }
public Atlas3() { m_time = 0; CCLayerColor col = new CCLayerColor(new CCColor4B(128, 128, 128, 255)); AddChild(col, -10); CCLabelBMFont label1 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label1.AnchorPoint = new CCPoint(0, 0); AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); CCActionInterval fade = new CCFadeOut (1.0f); CCFiniteTimeAction fade_in = fade.Reverse(); CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in); CCAction repeat = new CCRepeatForever ((CCActionInterval)seq); label1.RunAction(repeat); // 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 CCLabelBMFont label2 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label2.AnchorPoint = new CCPoint(0.5f, 0.5f); label2.Color = ccRED; AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2); label2.RunAction((CCAction)(repeat.Copy())); CCLabelBMFont label3 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label3.AnchorPoint = new CCPoint(1, 1); AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); CCSize s = CCDirector.SharedDirector.WinSize; label1.Position = new CCPoint(); label2.Position = new CCPoint(s.Width / 2, s.Height / 2); label3.Position = new CCPoint(s.Width, s.Height); base.Schedule(step);//:@selector(step:)]; }
public LabelTTFA8Test() { CCSize s = CCDirector.SharedDirector.WinSize; CCLayerColor layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255)); AddChild(layer, -10); // CCLabelBMFont CCLabelTTF label1 = new CCLabelTTF("Testing A8 Format", "Marker Felt", 38); AddChild(label1); label1.Color = CCTypes.CCRed; label1.Position = new CCPoint(s.Width / 2, s.Height / 2); CCFadeOut fadeOut = new CCFadeOut (2); CCFadeIn fadeIn = new CCFadeIn (2); CCFiniteTimeAction seq = new CCSequence(fadeOut, fadeIn); CCRepeatForever forever = new CCRepeatForever ((CCActionInterval) seq); label1.RunAction(forever); }
public LabelAtlasColorTest() { CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label1, 0, (int)TagSprite.kTagSprite1); label1.Position = new CCPoint(10, 100); label1.Opacity = 200; CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' '); AddChild(label2, 0, (int)TagSprite.kTagSprite2); label2.Position = new CCPoint(10, 200); label2.Color = ccRED; CCActionInterval fade = new CCFadeOut (1.0f); CCFiniteTimeAction fade_in = fade.Reverse(); CCFiniteTimeAction seq = CCSequence.FromActions(fade, fade_in); CCAction repeat = new CCRepeatForever ((CCActionInterval)seq); label2.RunAction(repeat); m_time = 0; Schedule(step); //:@selector(step:)]; }
public void addNewSprite() { CCSize s = CCDirector.SharedDirector.WinSize; 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(m_texture1, new CCRect(x, y, 85, 121)); node.AddChild(sprite); sprite.Position = (new CCPoint(p.X, p.Y)); CCActionInterval 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); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.FromActions(action, action_back)); sprite.RunAction(new CCRepeatForever (seq)); }
public TMXReadWriteTest() { m_gid = 0; CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test2"); AddChild(map, 0, kTagTileMap); 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)); //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 seq0 = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish); var seq1 = (CCActionInterval) (seq0.Copy()); var seq2 = (CCActionInterval) (seq0.Copy()); var 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; }
public override void OnEnter() { base.OnEnter(); centerSprites(2); m_tamara.Opacity = 0; var action1 = new CCFadeIn (1.0f); var action1Back = action1.Reverse(); var action2 = new CCFadeOut (1.0f); var action2Back = action2.Reverse(); m_tamara.RunAction(new CCSequence(action1, action1Back)); m_kathia.RunAction(new CCSequence(action2, action2Back)); }