英文:
Keeping and getting all game objects in libgdx
问题
我正在使用libgdx在场景2d中创建游戏。我需要保留所有游戏对象的列表。我有一个GameObject类,所有游戏对象都是从这个类继承的。问题是,如果你只是将它们存储在GameObject数组中,那么继承类的字段和方法会丢失,这对我来说是不可接受的。你能否建议如何解决这个问题,以及如何最好地保留所有游戏对象的列表?
英文:
I am creating a game on libgdx, using only scene2d. I need to keep a list of all game objects. I have a GameObject class from which all game objects are inherited. The problem is that if you simply store them in array of GameObject , then the fields and methods of the heir classes are lost, which is unacceptable to me. Can you advise how you can solve this problem and how best to keep a list of all game objects?
专注分享java语言的经验与见解,让所有开发者获益!
评论