Beispiel #1
0
        private static void loadFolders(List <XmlNode> folders)
        {
            for (int i = 0; i < folders.Count; i++)
            {
                XmlNode repo = folders[i];
                com.discobeard.spriter.dom.Folder folder = new com.discobeard.spriter.dom.Folder(
                    );
                folder.setId(XmlReader.getInt(repo, "id"));

                folder.setName(XmlReader.getAttribute(repo, "name"));
                List <XmlNode> files = XmlReader.getChildrenByName(repo, "file");
                for (int j = 0; j < files.Count; j++)
                {
                    XmlNode f = files[j];
                    com.discobeard.spriter.dom.File file = new com.discobeard.spriter.dom.File();
                    file.setId(XmlReader.getInt(f, "id"));
                    file.setName(XmlReader.getAttribute(f, "name"));
                    file.setWidth(XmlReader.getInt(f, "width"));
                    file.setHeight(XmlReader.getInt(f, "height"));
                    try
                    {
                        file.setPivotX(XmlReader.getFloat(f, "pivot_x"));
                        file.setPivotY(XmlReader.getFloat(f, "pivot_y"));
                    }
                    catch (System.Exception)
                    {
                        file.setPivotX(System.Convert.ToSingle(0));
                        file.setPivotY(System.Convert.ToSingle(1));
                    }
                    folder.getFile().Add(file);
                }
                data.getFolder().Add(folder);
            }
        }
Beispiel #2
0
                                                 > generateKeyFramePool(com.discobeard.spriter.dom.SpriterData data, com.discobeard.spriter.dom.Entity
                                                                        entity)
 {
     System.Collections.Generic.IList <com.brashmonkey.spriter.animation.SpriterAnimation
                                       > spriterAnimations = new System.Collections.Generic.List <com.brashmonkey.spriter.animation.SpriterAnimation
                                                                                                  >();
     System.Collections.Generic.IList <com.discobeard.spriter.dom.Animation> animations
         = entity.getAnimation();
     com.brashmonkey.spriter.mergers.SpriterAnimationBuilder frameBuilder = new com.brashmonkey.spriter.mergers.SpriterAnimationBuilder
                                                                                ();
     foreach (com.discobeard.spriter.dom.Animation anim in animations)
     {
         com.brashmonkey.spriter.animation.SpriterAnimation spriterAnimation = frameBuilder
                                                                               .buildAnimation(anim);
         bool found = false;
         foreach (com.brashmonkey.spriter.animation.SpriterKeyFrame key in spriterAnimation
                  .frames)
         {
             if (!found)
             {
                 found = key.getTime() == anim.getLength();
             }
             sort(key.getObjects());
             foreach (com.brashmonkey.spriter.objects.SpriterBone bone in key.getBones())
             {
                 foreach (com.brashmonkey.spriter.objects.SpriterBone bone2 in key.getBones())
                 {
                     if (bone2.hasParent())
                     {
                         if (!bone2.equals(bone) && bone2.getParentId() == bone.getId())
                         {
                             bone.addChildBone(bone2);
                         }
                     }
                 }
                 foreach (com.brashmonkey.spriter.objects.SpriterObject @object in key.getObjects(
                              ))
                 {
                     com.brashmonkey.spriter.file.Reference @ref = @object.getRef();
                     com.discobeard.spriter.dom.File        f    = data.getFolder()[@ref.folder].getFile()[@ref.
                                                                                                           file];
                     @ref.dimensions = new com.brashmonkey.spriter.SpriterRectangle(0, f.getHeight(),
                                                                                    f.getWidth(), 0f);
                     if (bone.getId() == @object.getParentId())
                     {
                         bone.addChildObject(@object);
                     }
                 }
             }
         }
         spriterAnimations.Add(spriterAnimation);
     }
     return(spriterAnimations);
 }
Beispiel #3
0
 private void loadResources()
 {
     for (int folder = 0; folder < spriterData.getFolder().Count; folder++)
     {
         for (int file = 0; file < spriterData.getFolder()[folder].getFile().Count; file++)
         {
             string folderName = spriterData.getFolder()[folder].getName();
             string fileName   = spriterData.getFolder()[folder].getFile()[file].getName();
             com.brashmonkey.spriter.file.Reference @ref = new com.brashmonkey.spriter.file.Reference
                                                               (folder, file, folderName, fileName);
             @ref.dimensions = new com.brashmonkey.spriter.SpriterRectangle(0, spriterData.getFolder
                                                                                ()[folder].getFile()[file].getHeight(), spriterData.getFolder()[folder].getFile(
                                                                                )[file].getWidth(), 0);
             @ref.pivotX = spriterData.getFolder()[folder].getFile()[file].getPivotX();
             @ref.pivotY = spriterData.getFolder()[folder].getFile()[file].getPivotY();
             loader.load(@ref, scmlFile.getParent() + "/" + fileName);
         }
     }
     this.loader.finishLoading();
 }