Simpleを使用して、XMLファイルをこのクラスに読み込もうとしています。クラスに正しく注釈を付けたかどうかは本当にわかりません。
この部分が必要かどうかわかりません:
public Frame()
{
super();
}
public Frame(int num, int x, int y, int width, int height,int offsetx,int offsety, int duration )
{
this.Num = num;
this.X = x;
this.Y = y;
this.Width = width;
this.Height = height;
this.OffsetX = offsetx;
this.OffsetY = offsety;
this.Duration = duration;]
super()は何をしますか?ゲッター/セッターは必要ですか?ゲッターまたはセッターを追加したものですか?彼らは自動的に自分自身を呼びますか、それとも何ですか?
フルクラスは次のとおりです。
public class SpriteAnimationManag
{
// Animation frame class
@Element(name = "Frame")
public class Frame
{
@Element(name = "Num")
public int Num;
@Element(name = "X")
public int X;
@Element(name = "Y")
public int Y;
@Element(name = "Width")
public int Width;
@Element(name = "Height")
public int Height;
@Element(name = "OffSetX")
public int OffsetX;
@Element(name = "OffSetY")
public int OffsetY;
@Element(name = "Duration")
public float Duration;
public Frame()
{
super();
}
public Frame(int num, int x, int y, int width, int height,int offsetx,int offsety, int duration )
{
this.Num = num;
this.X = x;
this.Y = y;
this.Width = width;
this.Height = height;
this.OffsetX = offsetx;
this.OffsetY = offsety;
this.Duration = duration;
}
}
// Animaiton class to hold the name and frames
public class Animation
{
@Element(name = "Name")
public String Name;
@Element(name = "FrameRate")
public int FrameRate;//may need elementarray or list???
@Element(name = "Loop")
public boolean Loop;
@Element(name = "Pingpong")
public boolean Pingpong;
@ElementArray(name = "Frames")
public Frame[] Frames;
public Animation()
{
super();
}
public Animation(String name, int framerate, boolean loop, boolean pingpong, Frame[] frames)
{
this.Name = name;
this.FrameRate = framerate;
this.Loop = loop;
this.Pingpong = pingpong;
this.Frames = frames;
}
}
// The Sprite Texture stores the Sprite Sheet path.fr
public class SpriteTexture
{
// The Sprite Sheet texture file path
@Element(name = "path")
public String Path;
public SpriteTexture()
{
super();
}
public SpriteTexture(String path)
{
this.Path = path;
}
}
// Aniamtion Set contains the Sprite Texture and Animaitons.
@Root(name = "Animations")
public static class XNAAnimationSet
{
// The sprite texture object
@Element(name = "Texture")
public SpriteTexture SpriteTexture;
// The animation array in the Animation Set
@ElementArray(name = "Animation")
public Animation[] Animations;
public XNAAnimationSet()
{
super();
}
public XNAAnimationSet(SpriteTexture spritetexture, Animation[] animations)
{
this.SpriteTexture = spritetexture;
this.Animations = animations;
}
}
// Sprite Animation Manager class
public final static class SpriteAnimationManager
{
private static final String XNAAnimationSet = null;//was static private static
public static int AnimationCount;
// Read the Sprite Sheet Description information from the description xml file
public static XNAAnimationSet Read(String filename) throws Exception
{
XNAAnimationSet animationSet = new XNAAnimationSet();
Serializer serializer = new Persister();
try {
animationSet = serializer.read(XNAAnimationSet.class, filename );
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
// Count the animations to Animation Count
AnimationCount = animationSet.Animations.length;
return animationSet;
}
}
}
クラスをファイルに書き込もうとして、何が読み取られているかを確認しようとしています。ファイルは作成されましたが、空です。
私がこれに正しく注釈を付けたかどうか誰かに教えてもらえますか?私は何が間違っているのですか?