/// <summary> /// Removes multiple Sprite Frames from a plist file. /// Sprite Frames stored in this file will be removed. /// It is convinient to call this method when a specific texture needs to be removed. /// @since v0.99.5 /// </summary> public void removeSpriteFramesFromFile(string plist) { string path = CCFileUtils.fullPathFromRelativePath(plist); Dictionary <string, object> dict = CCFileUtils.dictionaryWithContentsOfFile(path); removeSpriteFramesFromDictionary(dict); }
public bool initWithFile(string plistFile) { this.m_sPlistFile = CCFileUtils.fullPathFromRelativePath(plistFile); Dictionary <string, object> dictionary = CCFileUtils.dictionaryWithContentsOfFile(this.m_sPlistFile); return(this.initWithDictionary(dictionary)); }
/// <summary> /// Adds multiple Sprite Frames from a plist file. The texture will be associated with the created sprite frames. /// </summary> public void addSpriteFramesWithFile(string pszPlist, CCTexture2D pobTexture) { string pszPath = CCFileUtils.fullPathFromRelativePath(pszPlist); Dictionary <string, Object> dict = CCFileUtils.dictionaryWithContentsOfFile(pszPath); addSpriteFramesWithDictionary(dict, pobTexture); }
/// <summary> /// Adds multiple Sprite Frames from a plist file. /// A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png /// If you want to use another texture, you should use the addSpriteFramesWithFile:texture method. /// </summary> public void addSpriteFramesWithFile(string pszPlist) { string pszPath = CCFileUtils.fullPathFromRelativePath(pszPlist); Dictionary <string, Object> dict = CCFileUtils.dictionaryWithContentsOfFile(pszPath); string texturePath = ""; Dictionary <string, Object> metadataDict = dict.Keys.Contains("metadata") ? (Dictionary <string, Object>)dict["metadata"] : null; if (metadataDict != null) { // C.A suggested to use metadataDict here instead of 'dict' to prevent the file not found error. // try to read texture file name from meta data if (metadataDict.Keys.Contains("textureFileName")) { texturePath = (valueForKey("textureFileName", metadataDict)); } } if (!string.IsNullOrEmpty(texturePath)) { // build texture path relative to plist file texturePath = CCFileUtils.fullPathFromRelativeFile(texturePath, pszPath); } else { // build texture path by replacing file path,case xna resource has no extension,so we move the image to images folder texturePath = pszPath; int index = pszPath.IndexOf("/"); if (index < 0) { index = pszPath.IndexOf(@"\"); } if (index > 0) { texturePath = pszPath.Substring(0, index) + "/images" + pszPath.Substring(index); } CCLog.Log("cocos2d: CCSpriteFrameCache: Trying to use file {0} as texture", texturePath); } CCTexture2D pTexture = CCTextureCache.sharedTextureCache().addImage(texturePath); if (pTexture != null) { addSpriteFramesWithDictionary(dict, pTexture); } else { CCLog.Log("cocos2d: CCSpriteFrameCache: Couldn't load texture"); } }
public bool initWithTMXFile(string tmxFile) { this.m_pTilesets = new List <CCTMXTilesetInfo>(); this.m_pLayers = new List <CCTMXLayerInfo>(); this.m_sTMXFileName = CCFileUtils.fullPathFromRelativePath(tmxFile); this.m_pObjectGroups = new List <CCTMXObjectGroup>(); this.m_pProperties = new Dictionary <string, string>(); this.m_pTileProperties = new Dictionary <int, Dictionary <string, string> >(); this.m_sCurrentString = null; this.m_bStoringCharacters = false; this.m_nLayerAttribs = 1; this.m_nParentElement = 0; return(this.parseXMLFile(this.m_sTMXFileName)); }
public void addSpriteFramesWithFile(string pszPlist) { Dictionary <string, object> item; string str = CCFileUtils.fullPathFromRelativePath(pszPlist); Dictionary <string, object> strs = CCFileUtils.dictionaryWithContentsOfFile(str); string str1 = ""; if (strs.Keys.Contains <string>("metadata")) { item = (Dictionary <string, object>)strs["metadata"]; } else { item = null; } Dictionary <string, object> strs1 = item; if (strs1 != null && strs1.Keys.Contains <string>("textureFileName")) { str1 = this.valueForKey("textureFileName", strs1); } if (string.IsNullOrEmpty(str1)) { str1 = str; int num = str.IndexOf("/"); if (num < 0) { num = str.IndexOf("\\"); } if (num > 0) { str1 = string.Concat(str.Substring(0, num), "/images", str.Substring(num)); } CCLog.Log("cocos2d: CCSpriteFrameCache: Trying to use file {0} as texture", new object[] { str1 }); } else { str1 = CCFileUtils.fullPathFromRelativeFile(str1, str); } CCTexture2D cCTexture2D = CCTextureCache.sharedTextureCache().addImage(str1); if (cCTexture2D == null) { CCLog.Log("cocos2d: CCSpriteFrameCache: Couldn't load texture"); return; } this.addSpriteFramesWithDictionary(strs, cCTexture2D); }
/// <summary> /// initializes a TMX format witha tmx file /// </summary> public bool initWithTMXFile(string tmxFile) { m_pTilesets = new List <CCTMXTilesetInfo>(); m_pLayers = new List <CCTMXLayerInfo>(); m_sTMXFileName = CCFileUtils.fullPathFromRelativePath(tmxFile); m_pObjectGroups = new List <CCTMXObjectGroup>(); m_pProperties = new Dictionary <string, string>(); m_pTileProperties = new Dictionary <int, Dictionary <string, string> >(); // tmp vars m_sCurrentString = null; m_bStoringCharacters = false; m_nLayerAttribs = (int)TMXLayerAttrib.TMXLayerAttribNone; m_nParentElement = (int)TMXProperty.TMXPropertyNone; return(parseXMLFile(m_sTMXFileName)); }
public void removeSpriteFramesFromFile(string plist) { this.removeSpriteFramesFromDictionary(CCFileUtils.dictionaryWithContentsOfFile(CCFileUtils.fullPathFromRelativePath(plist))); }
public void addSpriteFramesWithFile(string pszPlist, CCTexture2D pobTexture) { string str = CCFileUtils.fullPathFromRelativePath(pszPlist); this.addSpriteFramesWithDictionary(CCFileUtils.dictionaryWithContentsOfFile(str), pobTexture); }