public SpriteBatchNodeAliased() { CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 10); AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121)); sprite1.Position = (new CCPoint(s.Width / 2 - 100, s.Height / 2)); batch.AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1); CCSprite sprite2 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121)); sprite2.Position = (new CCPoint(s.Width / 2 + 100, s.Height / 2)); batch.AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2); CCActionInterval scale = new CCScaleBy(2, 5); CCActionInterval scale_back = (CCActionInterval)scale.Reverse(); CCActionInterval seq = (CCActionInterval)(new CCSequence(scale, scale_back)); CCAction repeat = new CCRepeatForever (seq); CCAction repeat2 = (CCAction)(repeat.Copy()); sprite1.RunAction(repeat); sprite2.RunAction(repeat2); }
public TextLayer() { InitWithColor(CCTypes.CreateColor(32, 32, 32, 255)); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCNode node = new CCNode (); CCActionInterval effect = getAction(); node.RunAction(effect); AddChild(node, 0, EffectTestScene.kTagBackground); CCSprite bg = new CCSprite(TestResource.s_back3); node.AddChild(bg, 0); bg.AnchorPoint = new CCPoint(0.5f, 0.5f); bg.Position = new CCPoint(size.Width / 2, size.Height / 2); CCSprite grossini = new CCSprite(TestResource.s_pPathSister2); node.AddChild(grossini, 1); grossini.Position = new CCPoint(x / 3, y / 2); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back)))); //grossini.runAction(effect); CCSprite tamara = new CCSprite(TestResource.s_pPathSister1); node.AddChild(tamara, 1); tamara.Position = new CCPoint(2 * x / 3, y / 2); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32); label.Position = new CCPoint(x / 2, y - 80); AddChild(label); label.Tag = EffectTestScene.kTagLabel; CCMenuItemImage item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); CCMenuItemImage item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); CCMenuItemImage item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(size.Width / 2 - 100, 30); item2.Position = new CCPoint(size.Width / 2, 30); item3.Position = new CCPoint(size.Width / 2 + 100, 30); AddChild(menu, 1); Schedule(checkAnim); }
public override void OnEnter() { base.OnEnter(); float x, y; CCSize size = CCDirector.SharedDirector.WinSize; x = size.Width; y = size.Height; CCSprite bg = new CCSprite("Images/background3"); AddChild(bg, 0, EffectAdvanceScene.kTagBackground); bg.Position = new CCPoint(x / 2, y / 2); grossini = new CCSprite("Images/grossinis_sister2"); bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1); grossini.Position = new CCPoint(x / 3.0f, 200); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc, sc_back)))); tamara = new CCSprite("Images/grossinis_sister1"); bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2); tamara.Position = new CCPoint(2 * x / 3.0f, 200); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever ((CCActionInterval)(CCSequence.FromActions(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(title(), "arial", 28); label.Position = new CCPoint(x / 2, y - 80); AddChild(label); label.Tag = EffectAdvanceScene.kTagLabel; string strSubtitle = subtitle(); if (strSubtitle != null) { CCLabelTTF l = new CCLabelTTF(strSubtitle, "arial", 16); AddChild(l, 101); l.Position = new CCPoint(size.Width / 2, size.Height - 80); } CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback); CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback); CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = new CCPoint(0, 0); item1.Position = new CCPoint(size.Width / 2 - 100, 30); item2.Position = new CCPoint(size.Width / 2, 30); item3.Position = new CCPoint(size.Width / 2 + 100, 30); AddChild(menu, 1); }
public TextLayer() { InitWithColor(CCTypes.CreateColor(32, 32, 32, 255)); var node = new CCNode(); CCActionInterval effect = getAction(); node.RunAction(effect); AddChild(node, 0, EffectTestScene.kTagBackground); var bg = new CCSprite(TestResource.s_back3); node.AddChild(bg, 0); bg.AnchorPoint = new CCPoint(0.5f, 0.5f); bg.Position = CCVisibleRect.Center; var grossini = new CCSprite(TestResource.s_pPathSister2); node.AddChild(grossini, 1); grossini.Position = new CCPoint(CCVisibleRect.Left.X + CCVisibleRect.VisibleRect.Size.Width / 3, CCVisibleRect.Center.Y); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever((new CCSequence(sc, sc_back)))); var tamara = new CCSprite(TestResource.s_pPathSister1); node.AddChild(tamara, 1); tamara.Position = new CCPoint(CCVisibleRect.Left.X + 2 * CCVisibleRect.VisibleRect.Size.Width / 3, CCVisibleRect.Center.Y); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever((new CCSequence(sc2, sc2_back)))); var label = new CCLabelTTF(EffectTestScene.effectsList[EffectTestScene.actionIdx], "arial", 32); label.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Top.Y - 80); AddChild(label); label.Tag = EffectTestScene.kTagLabel; var item1 = new CCMenuItemImage(TestResource.s_pPathB1, TestResource.s_pPathB2, backCallback); var item2 = new CCMenuItemImage(TestResource.s_pPathR1, TestResource.s_pPathR2, restartCallback); var item3 = new CCMenuItemImage(TestResource.s_pPathF1, TestResource.s_pPathF2, nextCallback); var menu = new CCMenu(item1, item2, item3); menu.Position = CCPoint.Zero; item1.Position = new CCPoint(CCVisibleRect.Center.X - item2.ContentSize.Width * 2, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); item2.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); item3.Position = new CCPoint(CCVisibleRect.Center.X + item2.ContentSize.Width * 2, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); AddChild(menu, 1); Schedule(checkAnim); }
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 override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp2 = new CCSprite(TestResource.s_pPathSister2); CCSprite sp3 = new CCSprite(TestResource.s_pPathSister1); CCSprite sp4 = new CCSprite(TestResource.s_pPathSister2); sp1.Position = (new CCPoint(100, s.Height / 2)); sp2.Position = (new CCPoint(380, s.Height / 2)); AddChild(sp1); AddChild(sp2); sp3.Scale = (0.25f); sp4.Scale = (0.25f); sp1.AddChild(sp3); sp2.AddChild(sp4); CCActionInterval a1 = new CCRotateBy (2, 360); CCActionInterval a2 = new CCScaleBy(2, 2); CCAction action1 = new CCRepeatForever ((CCActionInterval)new CCSequence(a1, a2, a2.Reverse()) ); CCAction action2 = new CCRepeatForever ((CCActionInterval) (new CCSequence( (CCActionInterval) (a1.Copy()), (CCActionInterval) (a2.Copy()), a2.Reverse())) ); sp2.AnchorPoint = (new CCPoint(0, 0)); sp1.RunAction(action1); sp2.RunAction(action2); }
private void performanceActions(CCSprite pSprite) { CCSize size = CCDirector.SharedDirector.WinSize; pSprite.Position = new CCPoint((CCRandom.Next() % (int) size.Width), (CCRandom.Next() % (int) size.Height)); float period = 0.5f + (CCRandom.Next() % 1000) / 500.0f; CCRotateBy rot = new CCRotateBy (period, 360.0f * CCRandom.Float_0_1()); var rot_back = rot.Reverse(); CCAction permanentRotation = new CCRepeatForever (CCSequence.FromActions(rot, rot_back)); pSprite.RunAction(permanentRotation); float growDuration = 0.5f + (CCRandom.Next() % 1000) / 500.0f; CCActionInterval grow = new CCScaleBy(growDuration, 0.5f, 0.5f); CCAction permanentScaleLoop = new CCRepeatForever (new CCSequence (grow, grow.Reverse())); pSprite.RunAction(permanentScaleLoop); }
public override void OnEnter() { base.OnEnter(); CCSprite bg = new CCSprite("Images/background3"); AddChild(bg, 0, EffectAdvanceScene.kTagBackground); bg.Position = CCVisibleRect.Center; grossini = new CCSprite("Images/grossinis_sister2"); bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1); grossini.Position = new CCPoint(CCVisibleRect.Left.X + CCVisibleRect.VisibleRect.Size.Width / 3, CCVisibleRect.Center.Y); CCActionInterval sc = new CCScaleBy(2, 5); CCFiniteTimeAction sc_back = sc.Reverse(); grossini.RunAction(new CCRepeatForever ((CCActionInterval)(new CCSequence(sc, sc_back)))); tamara = new CCSprite("Images/grossinis_sister1"); bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2); tamara.Position = new CCPoint(CCVisibleRect.Left.X + 2 * CCVisibleRect.VisibleRect.Size.Width / 3, CCVisibleRect.Center.Y); CCActionInterval sc2 = new CCScaleBy(2, 5); CCFiniteTimeAction sc2_back = sc2.Reverse(); tamara.RunAction(new CCRepeatForever ((CCActionInterval)(new CCSequence(sc2, sc2_back)))); CCLabelTTF label = new CCLabelTTF(title(), "arial", 28); label.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Top.Y - 80); AddChild(label); label.Tag = EffectAdvanceScene.kTagLabel; CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback); CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback); CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback); CCMenu menu = new CCMenu(item1, item2, item3); menu.Position = CCPoint.Zero; item1.Position = new CCPoint(CCVisibleRect.Center.X - item2.ContentSize.Width * 2, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); item2.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); item3.Position = new CCPoint(CCVisibleRect.Center.X + item2.ContentSize.Width * 2, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2); AddChild(menu, 1); }
public Sprite6() { // small capacity. Testing resizing // Don't use capacity=1 in your real game. It is expensive to resize the capacity CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1); AddChild(batch, 0, kTagSpriteBatchNode); batch.IgnoreAnchorPointForPosition = true; CCSize s = CCDirector.SharedDirector.WinSize; batch.AnchorPoint = new CCPoint(0.5f, 0.5f); batch.ContentSize = (new CCSize(s.Width, s.Height)); // SpriteBatchNode actions CCActionInterval rotate = new CCRotateBy (5, 360); CCAction action = new CCRepeatForever (rotate); // SpriteBatchNode actions CCActionInterval rotate_back = (CCActionInterval)rotate.Reverse(); CCActionInterval rotate_seq = (CCActionInterval)(CCSequence.FromActions(rotate, rotate_back)); CCAction rotate_forever = new CCRepeatForever (rotate_seq); CCActionInterval scale = new CCScaleBy(5, 1.5f); CCActionInterval scale_back = (CCActionInterval)scale.Reverse(); CCActionInterval scale_seq = (CCActionInterval)(CCSequence.FromActions(scale, scale_back)); CCAction scale_forever = new CCRepeatForever (scale_seq); float step = s.Width / 4; for (int i = 0; i < 3; i++) { CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121)); sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2)); sprite.RunAction((CCAction)(action.Copy())); batch.AddChild(sprite, i); } batch.RunAction(scale_forever); batch.RunAction(rotate_forever); }
public TileMapTest() { CCTileMapAtlas map = CCTileMapAtlas.Create(s_TilesPng, s_LevelMapTga, 16, 16); // Convert it to "alias" (GL_LINEAR filtering) map.Texture.SetAntiAliasTexParameters(); CCSize s = map.ContentSize; CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height); // If you are not going to use the Map, you can free it now // NEW since v0.7 map.ReleaseMap(); AddChild(map, 0, kTagTileMap); map.AnchorPoint = (new CCPoint(0, 0.5f)); CCScaleBy scale = new CCScaleBy(4, 0.8f); CCFiniteTimeAction scaleBack = scale.Reverse(); var seq = new CCSequence(scale, scaleBack); map.RunAction(new CCRepeatForever ((CCActionInterval)seq)); }
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(new CCSequence(actionBy, actionBy.Reverse())); m_kathia.RunAction(new CCSequence(actionBy2, actionBy2.Reverse())); }
public override void OnEnter() { base.OnEnter(); m_nImageOffset = 0; CCSize size = CCDirector.SharedDirector.WinSize; CCLabelTTF label = new CCLabelTTF("Loading...", "Marker Felt", 32); label.Position = size.Center; AddChild(label, 10); CCScaleBy scale = new CCScaleBy(0.3f, 2); CCScaleBy scale_back = (CCScaleBy) scale.Reverse(); CCSequence seq = new CCSequence(scale, scale_back); label.RunAction(new CCRepeatForever(seq)); ScheduleOnce(LoadImages, 1.0f); }
public override void OnEnter() { base.OnEnter(); CCSize s = CCDirector.SharedDirector.WinSize; // // Sprite 1: GL_LINEAR // // Default filter is GL_LINEAR CCSprite sprite = new CCSprite("Images/grossinis_sister1"); sprite.Position = new CCPoint(s.Width / 3.0f, s.Height / 2.0f); AddChild(sprite); // this is the default filterting sprite.IsAntialiased = true; // // Sprite 1: GL_NEAREST // CCSprite sprite2 = new CCSprite("Images/grossinis_sister2"); sprite2.Position = new CCPoint(2 * s.Width / 3.0f, s.Height / 2.0f); AddChild(sprite2); // Use Nearest in this one sprite2.IsAntialiased = false; // scale them to show CCScaleBy sc = new CCScaleBy(3, 8.0f); CCScaleBy sc_back = (CCScaleBy) (sc.Reverse()); CCRepeatForever scaleforever = new CCRepeatForever((CCActionInterval) (new CCSequence(sc, sc_back))); CCRepeatForever scaleToo = (CCRepeatForever) (scaleforever.Copy()); sprite2.RunAction(scaleforever); sprite.RunAction(scaleToo); CCTextureCache.SharedTextureCache.DumpCachedTextureInfo(); }
public override void OnEnter() { base.OnEnter(); CCSize size = CCDirector.SharedDirector.WinSize; // The .png image MUST be power of 2 in order to create a continue effect. // eg: 32x64, 512x128, 256x1024, 64x64, etc.. var sprite = new CCSprite("Images/pattern1.png", new CCRect(0, 0, 4096, 4096)); AddChild(sprite, -1, (int) enumTag.kTagSprite1); sprite.Position = new CCPoint(size.Width / 2, size.Height / 2); // Cocos2D-XNA no longer uses TexParameters. Please use the XNA SamplerState // sprite.Texture.TexParameters = new CCTexParams() { MagFilter = (uint)All.Linear, // MinFilter = (uint)All.Linear, // WrapS = (uint)All.Repeat, // WrapT = (uint)All.Repeat // }; sprite.Texture.SamplerState = SamplerState.LinearWrap; var rotate = new CCRotateBy(4, 360); sprite.RunAction(rotate); var scale = new CCScaleBy(2, 0.04f); var scaleBack = (CCScaleBy) scale.Reverse(); var seq = new CCSequence(scale, scaleBack); sprite.RunAction(seq); }
public SpriteOffsetAnchorScale() { CCSize s = CCDirector.SharedDirector.WinSize; for (int i = 0; i < 3; i++) { CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFramesWithFile("animations/grossini.plist"); cache.AddSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray"); // // Animation using Sprite BatchNode // CCSprite sprite = new CCSprite("grossini_dance_01.png"); sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2)); CCSprite point = new CCSprite("Images/r1"); point.Scale = 0.25f; point.Position = sprite.Position; AddChild(point, 1); switch (i) { case 0: sprite.AnchorPoint = new CCPoint(0, 0); break; case 1: sprite.AnchorPoint = new CCPoint(0.5f, 0.5f); break; case 2: sprite.AnchorPoint = new CCPoint(1, 1); break; } point.Position = sprite.Position; var animFrames = new List<CCSpriteFrame>(14); string str = ""; for (int j = 0; j < 14; j++) { string temp = ""; if (j + 1 < 10) { temp = "0" + (j + 1); } else { temp = (j + 1).ToString(); } str = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = cache.SpriteFrameByName(str); animFrames.Add(frame); } CCAnimation animation = new CCAnimation(animFrames, 0.3f); sprite.RunAction(new CCRepeatForever (new CCAnimate (animation))); CCActionInterval scale = new CCScaleBy(2, 2); CCActionInterval scale_back = (CCActionInterval)scale.Reverse(); CCActionInterval seq_scale = (CCActionInterval)(new CCSequence(scale, scale_back)); sprite.RunAction(new CCRepeatForever (seq_scale)); AddChild(sprite, 0); //animFrames->release(); // win32 : memory leak 2010-0415 } }
public override void OnEnter() { base.OnEnter(); CCSize size = CCDirector.SharedDirector.WinSize; // The .png image MUST be power of 2 in order to create a continue effect. // eg: 32x64, 512x128, 256x1024, 64x64, etc.. var sprite = new CCSprite("Images/pattern1.png", new CCRect(0, 0, 512, 256)); AddChild(sprite, -1, (int)enumTag.kTagSprite1); sprite.Position = new CCPoint(size.Width/2,size.Height/2); #if OPENGL sprite.Texture.TexParameters = new CCTexParams() { MagFilter = (uint)All.Linear, MinFilter = (uint)All.Linear, WrapS = (uint)All.MirroredRepeat, WrapT = (uint)All.Repeat }; #else var state = new SamplerState(); state.AddressU = TextureAddressMode.Mirror; state.AddressV = TextureAddressMode.Wrap; sprite.Texture.SamplerState = state; #endif var rotate = new CCRotateBy(4, 360); sprite.RunAction(rotate); var scale = new CCScaleBy(2, 0.04f); var scaleBack = (CCScaleBy)scale.Reverse(); var seq = new CCSequence(scale, scaleBack); sprite.RunAction(seq); }
public SpriteOffsetAnchorSkewScale() { CCSize s = CCDirector.SharedDirector.WinSize; for (int i = 0; i < 3; i++) { CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFramesWithFile("animations/grossini.plist"); cache.AddSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray"); // // Animation using Sprite batch // CCSprite sprite = new CCSprite("grossini_dance_01.png"); sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2)); CCSprite point = new CCSprite("Images/r1"); point.Scale = 0.25f; point.Position = sprite.Position; AddChild(point, 1); switch (i) { case 0: sprite.AnchorPoint = new CCPoint(0, 0); break; case 1: sprite.AnchorPoint = (new CCPoint(0.5f, 0.5f)); break; case 2: sprite.AnchorPoint = (new CCPoint(1, 1)); break; } point.Position = sprite.Position; var animFrames = new List<CCSpriteFrame>(); string tmp = ""; for (int j = 0; j < 14; j++) { tmp = string.Format("grossini_dance_{0:00}.png", j + 1); CCSpriteFrame frame = cache.SpriteFrameByName(tmp); animFrames.Add(frame); } CCAnimation animation = new CCAnimation(animFrames, 0.3f); sprite.RunAction(new CCRepeatForever (new CCAnimate (animation))); animFrames = null; // Skew CCSkewBy skewX = new CCSkewBy (2, 45, 0); CCActionInterval skewX_back = (CCActionInterval)skewX.Reverse(); CCSkewBy skewY = new CCSkewBy (2, 0, 45); CCActionInterval skewY_back = (CCActionInterval)skewY.Reverse(); CCFiniteTimeAction seq_skew = new CCSequence(skewX, skewX_back, skewY, skewY_back); sprite.RunAction(new CCRepeatForever ((CCActionInterval)seq_skew)); // Scale CCScaleBy scale = new CCScaleBy(2, 2); CCActionInterval scale_back = (CCActionInterval)scale.Reverse(); CCFiniteTimeAction seq_scale = new CCSequence(scale, scale_back); sprite.RunAction(new CCRepeatForever ((CCActionInterval)seq_scale)); AddChild(sprite, 0); } }
public SpriteBatchNodeChildren() { CCSize s = CCDirector.SharedDirector.WinSize; // parents CCSpriteBatchNode batch = new CCSpriteBatchNode("animations/grossini", 50); AddChild(batch, 0, (int)kTags.kTagSpriteBatchNode); CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFramesWithFile("animations/grossini.plist"); CCSprite sprite1 = new CCSprite("grossini_dance_01.png"); sprite1.Position = (new CCPoint(s.Width / 3, s.Height / 2)); CCSprite sprite2 = new CCSprite("grossini_dance_02.png"); sprite2.Position = (new CCPoint(50, 50)); CCSprite sprite3 = new CCSprite("grossini_dance_03.png"); sprite3.Position = (new CCPoint(-50, -50)); batch.AddChild(sprite1); sprite1.AddChild(sprite2); sprite1.AddChild(sprite3); // BEGIN NEW CODE var animFrames = new List<CCSpriteFrame>(); string str = ""; for (int i = 1; i < 15; i++) { string temp = ""; if (i<10) { temp = "0" + i; } else { temp = i.ToString(); } str = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str); animFrames.Add(frame); } CCAnimation animation = new CCAnimation(animFrames, 0.2f); sprite1.RunAction(new CCRepeatForever (new CCAnimate (animation))); // END NEW CODE CCActionInterval action = new CCMoveBy (2, new CCPoint(200, 0)); CCActionInterval action_back = (CCActionInterval)action.Reverse(); CCActionInterval action_rot = new CCRotateBy (2, 360); CCActionInterval action_s = new CCScaleBy(2, 2); CCActionInterval action_s_back = (CCActionInterval)action_s.Reverse(); CCActionInterval seq2 = (CCActionInterval)action_rot.Reverse(); sprite2.RunAction(new CCRepeatForever (seq2)); sprite1.RunAction((CCAction)(new CCRepeatForever (action_rot))); sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(new CCSequence(action, action_back))))); sprite1.RunAction((CCAction)(new CCRepeatForever ((CCActionInterval)(new CCSequence(action_s, action_s_back))))); }
protected virtual CCAction ActionScale() { var scale = new CCScaleBy(1.33f, 1.5f); return new CCRepeatForever(new CCSequence(scale, scale.Reverse())); }
/// <summary> /// Creates a sequence of actions that causes a sprite to be scaled on the screen. /// </summary> /// <param name="repeatForever">A boolean value that determines if the action should be repeated indefinitely.</param> /// <returns></returns> internal static CCFiniteTimeAction ScaleAction(bool repeatForever) { // Create an action to scale the sprite to 1.5 times it's size CCActionInterval scaleAction = new CCScaleBy(0.2f, 1.5f); // Setup an action sequence to perform the scale action, then reverse it scaleAction = new CCSequence(scaleAction, scaleAction.Reverse()); // If necessary, repeat the scale actions above indefinitely if (repeatForever) scaleAction = new CCRepeatForever(scaleAction); return scaleAction; }