protected AnimationDescriptor generateAnimationDescriptor(Document document) {
		NodeList loopsList = document.getElementsByTagName("loops");
		String loopsValue = loopsList.item(0).getTextContent().trim();
		if (!(loopsValue.equals("true") || loopsValue.equals("false"))) {
			throw new GameLoadingError("Invalid loop attribute value: " + loopsValue);
		}
		boolean loops = loopsValue.equals("true") ? true : false;

		ArrayList<AnimationFrameDescriptor> animationFrameDescriptors = new ArrayList<AnimationFrameDescriptor>();
		NodeList frameList = document.getElementsByTagName("frame");
		for (int i = 0; i < frameList.getLength(); i++) {
			Node frame = frameList.item(i);
			String imageName = null;
			String percentage = null;
			for (int j = 0; j < frame.getChildNodes().getLength(); j++) {
				// TODO PROPER VALIDATION -> XERCES IS BUGGY
				Node node = frame.getChildNodes().item(j);
				String nodeName = node.getLocalName();
				if (nodeName != null) {

					if (nodeName.equals("imageName")) {
						imageName = node.getTextContent();
					} else if (nodeName.equals("percentage")) {
						percentage = node.getTextContent();
					} else {
						throw new GameLoadingError("Unrecognized element " + nodeName);
					}
				}
				//System.out.print("Child "+j+": ");
				//System.out.println(frame.getChildNodes().item(j).getTextContent());
			}
			AnimationFrameDescriptor animationFrameDescriptor = new AnimationFrameDescriptor(imageName, new Integer(percentage));
			animationFrameDescriptors.add(animationFrameDescriptor);
		}
		return new AnimationDescriptor(animationFrameDescriptors, loops);
	}