public LabelAtlasColorTest() { CCLabelAtlas label1 = CCLabelAtlas.labelWithString("123 Test", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' '); addChild(label1, 0, (int)TagSprite.kTagSprite1); label1.position = new CCPoint(10, 100); label1.Opacity = 200; CCLabelAtlas label2 = CCLabelAtlas.labelWithString("0123456789", "fonts/fnt/images/tuffy_bold_italic-charmap", 48, 64, ' '); addChild(label2, 0, (int)TagSprite.kTagSprite2); label2.position = new CCPoint(10, 200); label2.Color = ccRED; CCActionInterval fade = CCFadeOut.actionWithDuration(1.0f); CCFiniteTimeAction fade_in = fade.reverse(); CCFiniteTimeAction seq = CCSequence.actions(fade, fade_in); CCAction repeat = CCRepeatForever.actionWithAction((CCActionInterval)seq); label2.runAction(repeat); m_time = 0; schedule(step); //:@selector(step:)]; }
public override void OnEnter() { base.OnEnter(); var s = CCDirector.SharedDirector.WinSize; var layer1 = new CCLayerColor(new CCColor4B(255, 255, 0, 80), 100, s.Height - 50); 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), 100, s.Height - 50); 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); }
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 override void onEnter() { base.onEnter(); CCSize s = CCDirector.sharedDirector().getWinSize(); CCLayerColor layer1 = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 255, 0, 80), 100, 300); layer1.position = (new CCPoint(s.width / 3, s.height / 2)); layer1.isRelativeAnchorPoint = true; addChild(layer1, 1); CCLayerColor layer2 = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0, 0, 255, 255), 100, 300); layer2.position = (new CCPoint((s.width / 3) * 2, s.height / 2)); layer2.isRelativeAnchorPoint = true; addChild(layer2, 1); CCActionInterval actionTint = CCTintBy.actionWithDuration(2, -255, -127, 0); CCActionInterval actionTintBack = (CCActionInterval)actionTint.reverse(); CCActionInterval seq1 = (CCActionInterval)CCSequence.actions(actionTint, actionTintBack); layer1.runAction(seq1); CCActionInterval actionFade = CCFadeOut.actionWithDuration(2.0f); CCActionInterval actionFadeBack = (CCActionInterval)actionFade.reverse(); CCActionInterval seq2 = (CCActionInterval)CCSequence.actions(actionFade, actionFadeBack); layer2.runAction(seq2); }
private void DisplayHint() { _isDisplayingHint = true; var idx = FindMove(); var x = idx % Constants.KBoardWidth; var y = (int)Math.Floor((double)idx / Constants.KBoardWidth); var connected = FindConnectedGems(x, y); for (var i = 0; i < connected.Count; i++) { idx = connected[i]; x = idx % Constants.KBoardWidth; y = (int)Math.Floor((double)idx / Constants.KBoardWidth); var actionFadeIn = new CCFadeIn(0.5f); var actionFadeOut = new CCFadeOut(0.5f); var actionSeq = new CCSequence(actionFadeIn, actionFadeOut); var action = new CCRepeatForever(actionSeq); var hintSprite = new CCSprite("crystalscrystals/hint.png"); hintSprite.Opacity = 0; hintSprite.Position = new CCPoint(_fieldPositionZero.X + x * Constants.KGemSize, _fieldPositionZero.Y + y * Constants.KGemSize); hintSprite.AnchorPoint = CCPoint.Zero; _hintLayer.AddChild(hintSprite); hintSprite.RunAction(action); } }
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; }
public Atlas4() { m_time = 0; // Upper Label CCLabelBMFont label = CCLabelBMFont.labelWithString("Bitmap Font Atlas", "fonts/fnt/bitmapFontTest"); addChild(label); CCSize s = CCDirector.sharedDirector().getWinSize(); 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 = CCRotateBy.actionWithDuration(2, 360); CCAction rot_4ever = CCRepeatForever.actionWithAction(rotate); CCActionInterval scale = CCScaleBy.actionWithDuration(2, 1.5f); CCFiniteTimeAction scale_back = scale.reverse(); CCFiniteTimeAction scale_seq = CCSequence.actions(scale, scale_back); CCAction scale_4ever = CCRepeatForever.actionWithAction((CCActionInterval)scale_seq); CCActionInterval jump = CCJumpBy.actionWithDuration(0.5f, new CCPoint(), 60, 1); CCAction jump_4ever = CCRepeatForever.actionWithAction(jump); CCActionInterval fade_out = CCFadeOut.actionWithDuration(1); CCActionInterval fade_in = CCFadeIn.actionWithDuration(1); CCFiniteTimeAction seq = CCSequence.actions(fade_out, fade_in); CCAction fade_4ever = CCRepeatForever.actionWithAction((CCActionInterval)seq); BChar.runAction(rot_4ever); BChar.runAction(scale_4ever); FChar.runAction(jump_4ever); AChar.runAction(fade_4ever); // Bottom Label CCLabelBMFont label2 = CCLabelBMFont.labelWithString("00.0", "fonts/fnt/bitmapFontTest"); 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); }
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 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; }
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 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 = new CCSequence(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 Atlas3() { m_time = 0; CCLayerColor col = CCLayerColor.layerWithColor(new ccColor4B(128, 128, 128, 255)); addChild(col, -10); CCLabelBMFont label1 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2"); // testing anchors label1.anchorPoint = new CCPoint(0, 0); addChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1); CCActionInterval fade = CCFadeOut.actionWithDuration(1.0f); CCFiniteTimeAction fade_in = fade.reverse(); CCFiniteTimeAction seq = CCSequence.actions(fade, fade_in); CCAction repeat = CCRepeatForever.actionWithAction((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 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2"); // 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 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2"); // testing anchors label3.anchorPoint = new CCPoint(1, 1); addChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3); CCSize s = CCDirector.sharedDirector().getWinSize(); 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 override void onEnter() { base.onEnter(); centerSprites(2); m_tamara.Opacity = 0; CCActionInterval action1 = CCFadeIn.actionWithDuration(1.0f); CCFiniteTimeAction action1Back = action1.reverse(); CCActionInterval action2 = CCFadeOut.actionWithDuration(1.0f); CCFiniteTimeAction action2Back = action2.reverse(); m_tamara.runAction(CCSequence.actions(action1, action1Back)); m_kathia.runAction(CCSequence.actions(action2, action2Back)); }
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(CCSequence.FromActions(action1, action1Back)); m_kathia.RunAction(CCSequence.FromActions(action2, action2Back)); }
public void addNewSprite() { CCSize s = CCDirector.sharedDirector().getWinSize(); CCPoint p = new CCPoint((float)(rand.NextDouble() * s.width), (float)(rand.NextDouble() * s.height)); int idx = (int)(rand.NextDouble() * 1400 / 100); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCNode node = getChildByTag((int)kTags.kTagSpriteBatchNode); CCSprite sprite = CCSprite.spriteWithTexture(m_texture1, new CCRect(x, y, 85, 121)); node.addChild(sprite); sprite.position = (new CCPoint(p.x, p.y)); CCActionInterval action; float random = (float)rand.NextDouble(); if (random < 0.20) { action = CCScaleBy.actionWithDuration(3, 2); } else if (random < 0.40) { action = CCRotateBy.actionWithDuration(3, 360); } else if (random < 0.60) { action = CCBlink.actionWithDuration(1, 3); } else if (random < 0.8) { action = CCTintBy.actionWithDuration(2, 0, -255, -255); } else { action = CCFadeOut.actionWithDuration(2); } CCActionInterval action_back = (CCActionInterval)action.reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.actions(action, action_back)); sprite.runAction(CCRepeatForever.actionWithAction(seq)); }
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 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 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 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 void addNewSpriteWithCoords(CCPoint p) { CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)getChildByTag((int)kTags.kTagSpriteBatchNode); int idx = (int)(rand.NextDouble() * 1400 / 100); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCSprite sprite = CCSprite.spriteWithTexture(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)rand.NextDouble(); if (random < 0.20) { action = CCScaleBy.actionWithDuration(3, 2); } else if (random < 0.40) { action = CCRotateBy.actionWithDuration(3, 360); } else if (random < 0.60) { action = CCBlink.actionWithDuration(1, 3); } else if (random < 0.8) { action = CCTintBy.actionWithDuration(2, 0, -255, -255); } else { action = CCFadeOut.actionWithDuration(2); } CCActionInterval action_back = (CCActionInterval)action.reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.actions(action, action_back)); sprite.runAction(CCRepeatForever.actionWithAction(seq)); }
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 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; }
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; } ); }
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 void addNewSpriteWithCoords(CCPoint p) { int idx = (int)(ccMacros.CCRANDOM_0_1() * 1400.0f / 100.0f); int x = (idx % 5) * 85; int y = (idx / 5) * 121; CCSprite sprite = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(x, y, 85, 121)); addChild(sprite); sprite.position = p; CCActionInterval action; float random = ccMacros.CCRANDOM_0_1(); if (random < 0.20) { action = CCScaleBy.actionWithDuration(3, 2); } else if (random < 0.40) { action = CCRotateBy.actionWithDuration(3, 360); } else if (random < 0.60) { action = CCBlink.actionWithDuration(1, 3); } else if (random < 0.8) { action = CCTintBy.actionWithDuration(2, 0, -255, -255); } else { action = CCFadeOut.actionWithDuration(2); } object obj = action.reverse(); CCActionInterval action_back = (CCActionInterval)action.reverse(); CCActionInterval seq = (CCActionInterval)(CCSequence.actions(action, action_back)); sprite.runAction(CCRepeatForever.actionWithAction(seq)); }
public MainLayer() { base.isTouchEnabled = true; CCSprite sprite = CCSprite.spriteWithFile(ClickAndMoveTest.s_pPathGrossini); CCLayer layer = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 0, 255)); addChild(layer, -1); addChild(sprite, 0, ClickAndMoveTest.kTagSprite); sprite.position = new CCPoint(20, 150); sprite.runAction(CCJumpTo.actionWithDuration(4, new CCPoint(300, 48), 100, 4)); layer.runAction(CCRepeatForever.actionWithAction( (CCActionInterval)(CCSequence.actions( CCFadeIn.actionWithDuration(1), CCFadeOut.actionWithDuration(1))) )); }
public override void onEnter() { base.onEnter(); CCSprite child = CCSprite.spriteWithFile(s_pPathGrossini); child.position = (new CCPoint(200, 200)); addChild(child, 1); //Sum of all action's duration is 1.5 second. child.runAction(CCRotateBy.actionWithDuration(1.5f, 90)); child.runAction(CCSequence.actions( CCDelayTime.actionWithDuration(1.4f), CCFadeOut.actionWithDuration(1.1f)) ); //After 1.5 second, self will be removed. runAction(CCSequence.actions( CCDelayTime.actionWithDuration(1.4f), CCCallFunc.actionWithTarget(this, (removeThis))) ); }
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 = CCSequence.FromActions(fadeOut, fadeIn); CCRepeatForever forever = new CCRepeatForever((CCActionInterval)seq); label1.RunAction(forever); }
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); }
protected CCFadeOut(CCFadeOut fadeOut) : base(fadeOut) { }
public CCFadeOutState (CCFadeOut action, CCNode target) : base (action, target) { }