public void addFrameEventListener(System.Object target, Action <BBFlashMovie> callback) { if (_frameListeners == null) { _frameListeners = new List <FrameListener> (); } else { var enumerator = _frameListeners.GetEnumerator(); while (enumerator.MoveNext()) { var tmp = enumerator.Current; if (tmp.target == target && tmp.callback == callback) { CCDebug.Info("BBGamelib:flash: Frame event listener already exist."); return; } } } FrameListener listener = new FrameListener(); listener.target = target; listener.callback = callback; _frameListeners.Add(listener); }
/** 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. */ public void addSpriteFramesWithFile(string path) { string ext = Path.GetExtension(path); if (ext != null && ext.Length > 0) { path = path.Replace(ext, ""); } if (_loadedFilenames.Contains(path)) { CCDebug.Info("cocos2d: CCSpriteFrameCache: file already loaded: {0}", path); return; } else { _loadedFilenames.Add(path); } string cfgPath = path; if (!cfgPath.EndsWith("-tp")) { cfgPath += "-tp.txt"; } NSDictionary dict = NSDictionary.DictionaryWithContentsOfFileFromResources(cfgPath); string texturePath = path; Sprite[] sprites = Resources.LoadAll <Sprite> (texturePath); addSpriteFrames(dict, sprites); }
public void initWithImageNamed(string imageName) { gameObject.name = imageName; CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache.spriteFrameByName(imageName); if (frame == null) { CCDebug.Info("cocos2d:CCSprite: Try to load '{0}' as a file.", imageName); frame = new CCSpriteFrame(imageName); } initWithSpriteFrame(frame); }
/** Returns an Sprite Frame that was previously added. * If the name is not found it will return nil. * You should retain the returned copy if you are going to use it. */ public CCSpriteFrame spriteFrameByName(string name) { CCSpriteFrame frame; if (!_spriteFrames.TryGetValue(name, out frame)) { // try alias dictionary string key; if (_spriteFramesAliases.TryGetValue(name, out key)) { _spriteFrames.TryGetValue(key, out frame); } if (frame == null) { CCDebug.Info("cocos2d: CCSpriteFrameCache: Frame '{0}' not found", name); } } return(frame); }