我不知道如何解决这个问题。Array<>
我需要为在 libgdx 中找到的对象编写一个序列化程序。
public static void initialize(Server server) {
Kryo kryo = server.getKryo();
kryo.register(ServerData.class);
kryo.register(PlayerNick.class);
kryo.register(MoveLeft.class);
kryo.register(MoveRight.class);
kryo.register(MoveUp.class);
kryo.register(MoveDown.class);
kryo.register(StandUp.class);
kryo.register(ButtonLeft.class);
kryo.register(ButtonRight.class);
//
kryo.register(PlayerData.class);
kryo.register(Vector2.class);
kryo.register(Array.class);
kryo.register(PlayerDataPacket.class);
}
public static void initialize(Client client) {
Kryo kryo = client.getKryo();
kryo.register(ServerData.class);
kryo.register(PlayerNick.class);
kryo.register(MoveLeft.class);
kryo.register(MoveRight.class);
kryo.register(MoveUp.class);
kryo.register(MoveDown.class);
kryo.register(StandUp.class);
kryo.register(ButtonLeft.class);
kryo.register(ButtonRight.class);
//
kryo.register(PlayerData.class);
kryo.register(Vector2.class);
kryo.register(Array.class);
kryo.register(PlayerDataPacket.class);
}
public static class PlayerData {
public String name;
public int id;
public Vector2 position;
}
public static class PlayerDataPacket {
public Array<PlayerData> playerList = new Array<PlayerData>();
}
这就是我通常的序列化完成的方式。在这里,我需要为PlayerDataPacket
.
我发现了这个:https ://groups.google.com/forum/#!topic/kryonet-users/9z4Ix2JO7JA
但它似乎已经过时了,因为它找不到一些方法,而且它没有说明如何用Array<>
.