public SpriteBatchNodeOffsetAnchorSkewScale() { CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFrames("animations/grossini.plist"); cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray"); // Create animations and actions var animFrames = new List <CCSpriteFrame>(); string tmp = ""; for (int j = 0; j < 14; j++) { string temp = ""; if (j + 1 < 10) { temp = "0" + (j + 1); } else { temp = (j + 1).ToString(); } tmp = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = cache[tmp]; animFrames.Add(frame); } animation = new CCAnimation(animFrames, 0.3f); // skew CCSkewBy skewX = new CCSkewBy(2, 45, 0); CCFiniteTimeAction skewX_back = (CCFiniteTimeAction)skewX.Reverse(); CCSkewBy skewY = new CCSkewBy(2, 0, 45); CCFiniteTimeAction skewY_back = (CCFiniteTimeAction)skewY.Reverse(); // scale CCScaleBy scale = new CCScaleBy(2, 2); CCFiniteTimeAction scale_back = (CCFiniteTimeAction)scale.Reverse(); seq_scale = new CCSequence(scale, scale_back); seq_skew = new CCSequence(skewX, skewX_back, skewY, skewY_back); sprites = new CCSprite[numOfSprites]; pointSprites = new CCSprite[numOfSprites]; for (int i = 0; i < numOfSprites; i++) { // Animation using Sprite batch sprites[i] = new CCSprite("grossini_dance_01.png"); pointSprites[i] = new CCSprite("Images/r1"); CCSpriteBatchNode spritebatch = new CCSpriteBatchNode("animations/grossini"); AddChild(spritebatch); AddChild(pointSprites[i], 200); spritebatch.AddChild(sprites[i], i); } }
public override void OnEnter() { base.OnEnter(); centerSprites(3); var actionTo = new CCSkewTo(2, 37.2f, -37.2f); var actionToBack = new CCSkewTo(2, 0, 0); var actionBy = new CCSkewBy(2, 0.0f, -90.0f); var actionBy2 = new CCSkewBy(2, 45.0f, 45.0f); var actionByBack = actionBy.Reverse(); m_tamara.RunAction(CCSequence.FromActions(actionTo, actionToBack)); m_grossini.RunAction(CCSequence.FromActions(actionBy, actionByBack)); m_kathia.RunAction(CCSequence.FromActions(actionBy2, actionBy2.Reverse())); }
public SpriteOffsetAnchorSkew() { CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFrames("animations/grossini.plist"); cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray"); sprites = new CCSprite[numOfSprites]; pointSprites = new CCSprite[numOfSprites]; 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[tmp]; animFrames.Add(frame); } animation = new CCAnimation(animFrames, 0.3f); // Skew CCSkewBy skewX = new CCSkewBy(2, 45, 0); CCFiniteTimeAction skewX_back = (CCFiniteTimeAction)skewX.Reverse(); CCSkewBy skewY = new CCSkewBy(2, 0, 45); CCFiniteTimeAction skewY_back = (CCFiniteTimeAction)skewY.Reverse(); seq_skew = new CCSequence(skewX, skewX_back, skewY, skewY_back); for (int i = 0; i < numOfSprites; i++) { // Animation using Sprite batch sprites[i] = new CCSprite("grossini_dance_01.png"); AddChild(sprites[i], 0); pointSprites[i] = new CCSprite("Images/r1"); AddChild(pointSprites[i], 1); } }
public SpriteBatchNodeOffsetAnchorSkew() { 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, 200); 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; CCSpriteBatchNode spritebatch = new CCSpriteBatchNode("animations/grossini"); AddChild(spritebatch); var animFrames = new List <CCSpriteFrame>(); string tmp = ""; for (int j = 0; j < 14; j++) { string temp = ""; if (j + 1 < 10) { temp = "0" + (j + 1); } else { temp = (j + 1).ToString(); } tmp = string.Format("grossini_dance_{0}.png", temp); CCSpriteFrame frame = cache.SpriteFrameByName(tmp); animFrames.Add(frame); } CCAnimation animation = new CCAnimation(animFrames, 0.3f); sprite.RunAction(new CCRepeatForever(new CCAnimate(animation))); animFrames = null; 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 = CCSequence.FromActions(skewX, skewX_back, skewY, skewY_back); sprite.RunAction(new CCRepeatForever((CCActionInterval)seq_skew)); spritebatch.AddChild(sprite, i); } }