public SpriteOffsetAnchorRotation() { sprites = new CCSprite[numOfSprites]; pointSprites = new CCSprite[numOfSprites]; // Create actions CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFrames("animations/grossini.plist"); cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray"); 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); 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 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 SpriteBatchNodeOffsetAnchorFlip() { 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); CCFlipY flip = new CCFlipY(true); CCFlipY flip_back = new CCFlipY(false); CCDelayTime delay = new CCDelayTime(1); seq = new CCSequence(delay, flip, delay, flip_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 IntroLayer() : base(CCColor4B.Gray) { titleLabel = new CCLabel("CocosJuce", "fonts/Roboto-Light-72.fnt"); frequencyLabel = new CCLabel("", "fonts/Roboto-Light-72.fnt"); onOffSwitchSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache; onOffSwitchSpriteFrameCache.AddSpriteFrames("images/onoffswitch.plist"); switchOnSprite = new CCSprite("switch_on.png"); switchOffSprite = new CCSprite("switch_off.png"); onOffSwitch = new CCMenuItemToggle(SwitchToggle, new CCMenuItem[] { new CCMenuItemImage(switchOffSprite) { }, new CCMenuItemImage(switchOnSprite) { }, }); menu = new CCMenu(onOffSwitch); freqKnobSpriteFrameCache = CCSpriteFrameCache.SharedSpriteFrameCache; freqKnobSpriteFrameCache.AddSpriteFrames("images/frequencyknob.plist"); frequencyKnob = new CCSprite("frequencyknob00.png"); AddChild(titleLabel); AddChild(menu); AddChild(frequencyLabel); AddChild(frequencyKnob); }
public SpriteFrameAliasNameTest() { CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFrames("animations/grossini-aliases.plist", "animations/grossini-aliases"); var animFrames = new List <CCSpriteFrame>(15); string str = ""; for (int i = 1; i < 15; i++) { // Obtain frames by alias name str = string.Format("dance_{0:00}", i); CCSpriteFrame frame = cache[str]; animFrames.Add(frame); } animation = new CCAnimation(animFrames, 0.3f); sprite = new CCSprite("grossini_dance_01.png"); CCSprite spriteBatch = new CCSprite("animations/grossini-aliases"); AddChild(sprite); }
public SpriteOffsetAnchorScale() { 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>(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[str]; animFrames.Add(frame); } animation = new CCAnimation(animFrames, 0.3f); for (int i = 0; i < numOfSprites; i++) { // Animation using Sprite BatchNode sprites[i] = new CCSprite("grossini_dance_01.png"); AddChild(sprites[i], 0); pointSprites[i] = new CCSprite("Images/r1"); AddChild(pointSprites[i], 1); CCFiniteTimeAction scale = new CCScaleBy(2, 2); CCFiniteTimeAction scale_back = (CCFiniteTimeAction)scale.Reverse(); seq_scale = (CCFiniteTimeAction)(new CCSequence(scale, scale_back)); } }
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 SpriteFrameTest() { CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFrames("animations/grossini.plist"); cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray"); cache.AddSpriteFrames("animations/grossini_blue.plist", "animations/grossini_blue"); var animFrames = new List <CCSpriteFrame>(15); string str = ""; for (int i = 1; i < 15; i++) { str = string.Format("grossini_dance_{0:00}.png", i); CCSpriteFrame frame = cache[str]; animFrames.Add(frame); } animation = new CCAnimation(animFrames, 0.3f); var moreFrames = new List <CCSpriteFrame>(20); for (int i = 1; i < 15; i++) { string temp; str = string.Format("grossini_dance_gray_{0:00}.png", i); CCSpriteFrame frame = cache[str]; moreFrames.Add(frame); } for (int i = 1; i < 5; i++) { str = string.Format("grossini_blue_{0:00}.png", i); CCSpriteFrame frame = cache[str]; moreFrames.Add(frame); } // append frames from another batch moreFrames.AddRange(animFrames); animMixed = new CCAnimation(moreFrames, 0.3f); CCSprite spritebatch = new CCSprite("animations/grossini"); sprite1 = new CCSprite("grossini_dance_01.png"); AddChild(sprite1); // to test issue #732, uncomment the following line sprite1.FlipX = false; sprite1.FlipY = false; // Animation using standard Sprite sprite2 = new CCSprite("grossini_dance_01.png"); AddChild(sprite2); // to test issue #732, uncomment the following line sprite2.FlipX = false; sprite2.FlipY = false; }
static void cacheSpriteFramesInfo(string imageDevPath, LHScene scene) { string sceneRelative = scene.relativePath; string curDevSuffix = scene.currentDeviceSuffix(true); string atlasName = LHUtils.stripExtension(imageDevPath); // string atlasName = Path.GetFileNameWithoutExtension(imageDevPath); string atlasPlist = atlasName + ".plist"; // string atlasPlist = Path.ChangeExtension (atlasName, "plist"); string sceneSuf = sceneRelative + curDevSuffix; // atlasPlist = sceneSuf + atlasPlist; // Debug.WriteLine ("atlasPlist"); // Debug.WriteLine (atlasPlist); // string sceneSuf = Path.Combine (sceneRelative, curDevSuffix); // atlasPlist = Path.Combine (sceneSuf, atlasPlist); CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache; cache.AddSpriteFrames(atlasPlist); atlasName = sceneRelative + atlasName; // atlasName = Path.Combine (sceneRelative, atlasName); if (false == scene.hasEditorBodyInfoForImageFilePath(atlasName)) { string path = CCFileUtils.FullPathFromRelativePath(atlasPlist); PlistDocument document = CCContentManager.SharedContentManager.Load <PlistDocument>(path); PlistDictionary dict = document.Root.AsDictionary; PlistDictionary framesDict = dict ["frames"].AsDictionary; foreach (var pair in framesDict) { string sprName = pair.Key; PlistDictionary frmInfo = pair.Value.AsDictionary; if (null != frmInfo) { PlistDictionary bodyInfo = frmInfo ["body"].AsDictionary; if (null != bodyInfo) { Debug.WriteLine("CACHING BODY " + sprName + " atlas " + atlasName + " body " + bodyInfo); scene.setEditorBodyInfoForSpriteName(sprName, atlasName, bodyInfo); } } } } }