Beispiel #1
0
    /**
     * Loads an animation from a filename
     *
     * @param filename
     *            The xml descriptor for the animation
     * @return the loaded Animation
     */
    public static Animation loadAnimation(InputStreamCreator isCreator, string filename, ImageLoaderFactory imageloader)
    {
        AnimationHandler_ animationHandler = new AnimationHandler_(isCreator, imageloader);

        // Create a new factory
        //factory.setValidating(false);
        //SAXParser saxParser;
        try
        {
            //saxParser = factory.newSAXParser();

            // Read and close the input stream
            //File file = new File(filename);
            string descriptorIS = null;
            /*try {
                System.out.println("FILENAME="+filename);
                descriptorIS = ResourceHandler.getInstance( ).buildInputStream(filename);
                System.out.println("descriptorIS==null?"+(descriptorIS==null));

                //descriptorIS = new InputStream(ResourceHandler.getInstance().getResourceAsURLFromZip(filename));
            } catch (Exception e) { Debug.LogError(e); } {
                e.printStackTrace();
            }
            if (descriptorIS == null) {
                descriptorIS = AssetsController.getInputStream(filename);
            }*/
            descriptorIS = isCreator.buildInputStream("Assets/Resources/" + filename);
            if (!descriptorIS.EndsWith(".eaa"))
                descriptorIS += ".eaa";
            animationHandler.Parse(descriptorIS);
            //saxParser.parse(descriptorIS, animationHandler);
            //descriptorIS.close();

        }
        catch (Exception e) { Debug.LogError(e); }
        //catch (ParserConfigurationException e)
        //{
        //    e.printStackTrace();
        //    System.err.println(filename);
        //}
        //catch (SAXException e)
        //{
        //    e.printStackTrace();
        //    System.err.println(filename);
        //}
        //catch (FileNotFoundException e)
        //{
        //    e.printStackTrace();
        //    System.err.println(filename);
        //}
        //catch (IOException e)
        //{
        //    e.printStackTrace();
        //    System.err.println(filename);
        //}

        if (animationHandler.getAnimation() != null)
            return animationHandler.getAnimation();
        else
            return new Animation("anim" + (new System.Random()).Next(1000), imageloader);
    }
Beispiel #2
0
    /**
     * Loads an animation from a filename
     *
     * @param filename
     *            The xml descriptor for the animation
     * @return the loaded Animation
     */
    public static Animation loadAnimation(InputStreamCreator isCreator, string filename, ImageLoaderFactory imageloader)
    {
        AnimationHandler_ animationHandler = new AnimationHandler_(isCreator, imageloader);

        // Create a new factory
        //factory.setValidating(false);
        //SAXParser saxParser;
        try
        {
            //saxParser = factory.newSAXParser();

            // Read and close the input stream
            //File file = new File(filename);
            string descriptorIS = null;

            /*try {
             *  System.out.println("FILENAME="+filename);
             *  descriptorIS = ResourceHandler.getInstance( ).buildInputStream(filename);
             *  System.out.println("descriptorIS==null?"+(descriptorIS==null));
             *
             *  //descriptorIS = new InputStream(ResourceHandler.getInstance().getResourceAsURLFromZip(filename));
             * } catch (Exception e) { Debug.LogError(e); } {
             *  e.printStackTrace();
             * }
             * if (descriptorIS == null) {
             *  descriptorIS = AssetsController.getInputStream(filename);
             * }*/
            descriptorIS = isCreator.buildInputStream("Assets/Resources/" + filename);
            if (!descriptorIS.EndsWith(".eaa"))
            {
                descriptorIS += ".eaa";
            }
            animationHandler.Parse(descriptorIS);
            //saxParser.parse(descriptorIS, animationHandler);
            //descriptorIS.close();
        }
        catch (Exception e) { Debug.LogError(e); }
        //catch (ParserConfigurationException e)
        //{
        //    e.printStackTrace();
        //    System.err.println(filename);
        //}
        //catch (SAXException e)
        //{
        //    e.printStackTrace();
        //    System.err.println(filename);
        //}
        //catch (FileNotFoundException e)
        //{
        //    e.printStackTrace();
        //    System.err.println(filename);
        //}
        //catch (IOException e)
        //{
        //    e.printStackTrace();
        //    System.err.println(filename);
        //}

        if (animationHandler.getAnimation() != null)
        {
            return(animationHandler.getAnimation());
        }
        else
        {
            return(new Animation("anim" + (new System.Random()).Next(1000), imageloader));
        }
    }