コード例 #1
0
 public SpriteStudioNode()
 {
     BaseState = new SpriteStudioNodeState
     {
         Position     = Vector2.Zero,
         RotationZ    = 0.0f,
         Priority     = 0,
         Scale        = Vector2.One,
         Transparency = 1.0f,
         Hide         = 1,
         SpriteId     = -1,
         BlendColor   = Color.White,
         BlendType    = SpriteStudioBlending.Mix,
         BlendFactor  = 0.0f
     };
 }
コード例 #2
0
ファイル: SpriteStudioProcessor.cs プロジェクト: vvvv/stride
        private static SpriteStudioNodeState InitializeNodes(SpriteStudioComponent spriteStudioComponent)
        {
            var nodes = spriteStudioComponent.Sheet?.NodesInfo;

            if (nodes == null)
            {
                return(null);
            }

            //check if the sheet name dictionary has already been populated
            if (spriteStudioComponent.Sheet.Sprites == null)
            {
                spriteStudioComponent.Sheet.Sprites = new Sprite[spriteStudioComponent.Sheet.SpriteSheet.Sprites.Count];
                for (int i = 0; i < spriteStudioComponent.Sheet.SpriteSheet.Sprites.Count; i++)
                {
                    spriteStudioComponent.Sheet.Sprites[i] = spriteStudioComponent.Sheet.SpriteSheet.Sprites[i];
                }
            }

            foreach (var node in nodes)
            {
                var nodeState = new SpriteStudioNodeState
                {
                    Position     = node.BaseState.Position,
                    RotationZ    = node.BaseState.RotationZ,
                    Priority     = node.BaseState.Priority,
                    Scale        = node.BaseState.Scale,
                    Transparency = node.BaseState.Transparency,
                    Hide         = node.BaseState.Hide,
                    BaseNode     = node,
                    HFlipped     = node.BaseState.HFlipped,
                    VFlipped     = node.BaseState.VFlipped,
                    SpriteId     = node.BaseState.SpriteId,
                    BlendColor   = node.BaseState.BlendColor,
                    BlendType    = node.BaseState.BlendType,
                    BlendFactor  = node.BaseState.BlendFactor
                };

                nodeState.Sprite = nodeState.SpriteId != -1 ? spriteStudioComponent.Sheet.Sprites[nodeState.SpriteId] : null;

                spriteStudioComponent.Nodes.Add(nodeState);
            }

            SpriteStudioNodeState rootNode = null;

            for (var i = 0; i < nodes.Count; i++)
            {
                var nodeState = spriteStudioComponent.Nodes[i];
                var nodeAsset = nodes[i];

                if (nodeAsset.ParentId == -1)
                {
                    rootNode = nodeState;
                }
                else
                {
                    nodeState.ParentNode = spriteStudioComponent.Nodes.FirstOrDefault(x => x.BaseNode.Id == nodeAsset.ParentId);
                }

                foreach (var subNode in spriteStudioComponent.Nodes.Where(subNode => subNode.BaseNode.ParentId == nodeAsset.Id))
                {
                    nodeState.ChildrenNodes.Add(subNode);
                }
            }

            return(rootNode);
        }