[英]Representing players with 1..N coords in Java
my question is how would you do it to make a code as, 我的问题是您将如何编写代码,
i need a list with players[unique] and for every player i got these coords [x, z] 我需要一个有球员的列表[唯一],并且对于每个球员,我都有这些坐标[x,z]
but for every player there can be more than 1 coordinates[x,z] 但每个玩家最多可以有1个坐标[x,z]
i need to save it easly and i have to check the coords of the players every time they trigger an event... 我需要轻松保存它,并且每次触发事件时都要检查玩家的坐标...
so i have no idea where to start 所以我不知道从哪里开始
my english aint good so i gonne try to draw it a little for you hehe 我的英语不是很好,所以我要为你画一点
For every player, store the coordinates list in an ArrayList (where Point is a structure that holds the (x,y) coordinates--perhaps java.awt.Point). 对于每个玩家,将坐标列表存储在ArrayList中(其中Point是一个保存(x,y)坐标的结构-也许是java.awt.Point)。 Make Point implement Serializable .
使Point实现Serializable 。 (java.awt.Point already implements Serializable.) Also make the player class implement Serializable.
(java.awt.Point已经实现了Serializable。)还要使播放器类实现Serializable。 Then it is easy to serialize and deserialize each player (or an ArrayList of them) using ObjectOutputStream / ObjectInputStream .
然后,可以使用ObjectOutputStream / ObjectInputStream轻松序列化和反序列化每个播放器(或其中的ArrayList)。
this one is resolved 这个解决了
made 2 classes Coordinate and Player and made in player an arraylist of coordinate 制作了2个类的Coordinate和Player,并在player中制作了一个坐标数组
in the main class i make an arraylist of player... 在主要课程中,我列出了玩家的数组列表...
Saving happens with xml 使用XML进行保存
thx anyway for the help ! 无论如何寻求帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.