Ejemplo n.º 1
0
        private void ProcessAnimationElement(SuperTile tile, XElement xAnimation)
        {
            var fps        = m_Importer.SuperImportContext.Settings.AnimationFramerate;
            var animations = new AnimationBuilder(fps);

            var frameSprites   = xAnimation.Elements("frame").Select(f => f.GetAttributeAs <int>("tileid")).Select(index => m_TilesetScript.m_Tiles[index].m_Sprite).ToArray();
            var frameDurations = xAnimation.Elements("frame").Select(f => f.GetAttributeAs <int>("duration")).Select(ms => ms / 1000.0f).ToArray();

            for (int i = 0; i < frameSprites.Length; i++)
            {
                var sprite   = frameSprites[i];
                var duration = frameDurations[i];
                animations.AddFrames(sprite, duration);
            }

            tile.m_AnimationSprites = animations.Sprites.ToArray();
        }
Ejemplo n.º 2
0
        private void ProcessAnimationElement(SuperTile tile, XElement xAnimation)
        {
            var fps        = m_Importer.SuperImportContext.Settings.AnimationFramerate;
            var animations = new AnimationBuilder(fps);

            foreach (var xFrame in xAnimation.Elements("frame"))
            {
                var frameId       = xFrame.GetAttributeAs <int>("tileid");
                var frameDuration = xFrame.GetAttributeAs <int>("duration") / 1000.0f;

                SuperTile frame;
                if (m_TilesetScript.TryGetTile(frameId, out frame))
                {
                    animations.AddFrames(frame.m_Sprite, frameDuration);
                }
            }

            tile.m_AnimationSprites = animations.Sprites.ToArray();
        }