Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Greenfoot 程序创建游戏,但无法在构造函数中实例化任何内容。出于某种原因,当我getWorld().addObject()在构造函数中编写时,什么也没做。
getWorld().addObject()
act()不过,我可以在方法中创建对象。
act()
由于 Greenfoot 只允许您从世界对象添加对象,因此您调用的其他演员还不存在。这意味着没有构造函数可以调用getworld()。
getworld()