protected override void LoadContent() { base.LoadContent(); spriteBatch = new SpriteBatch(GraphicsDevice); spriteFont = Content.Load <SpriteFont>(FontName); Vector2 charPosition = new Vector2(Width / 2.0f, Height / 1.5f); foreach (var pair in Scmls) { string scmlPath = pair.Key; string spriterName = pair.Value; string data = File.ReadAllText(scmlPath); Spriter spriter = SpriterParser.Parse(data); foreach (SpriterEntity entity in spriter.Entities) { var animator = new MonogameSpriterAnimator(entity, charPosition, spriteBatch, GraphicsDevice); RegisterTextures(animator, spriter, spriterName); animators.Add(animator); } } currentAnimator = animators.First(); currentAnimator.EventTriggered += CurrentAnimator_EventTriggered; }
private void SwitchEntity() { int index = animators.IndexOf(currentAnimator); ++index; if (index >= animators.Count) { index = 0; } currentAnimator = animators[index]; }
private void RegisterTextures(MonogameSpriterAnimator animator, Spriter spriter, string spriterName) { foreach (SpriterFolder folder in spriter.Folders) { foreach (SpriterFile file in folder.Files) { string path = FormatPath(folder, file, spriterName); if (file.Type == SpriterFileType.Sound) { SoundEffect sound = LoadContent <SoundEffect>(path); animator.Register(folder.Id, file.Id, sound); } else { Texture2D texture = LoadContent <Texture2D>(path); if (texture != null) { animator.Register(folder.Id, file.Id, texture); } } } } }