-1

我正在为 Greenfoot 的学校编写一个插件,我可以使用该插件对在田野上移动的漫游车进行编程......

我想添加两个带有“addObject”的对象。

Mark mark = new Mark();
Rover rover = new Rover();
      addObject(mark && rover, 0, (int)(Math.random() *getHeight()));

这是不可能的。有没有办法完成这件事?我希望你明白我的意思:)

4

1 回答 1

0

First get the numbers you need and store them as variables:

int markRoverY = (int)(Math.random()*getHeight());

and then add the objects with the same variable

addObject(mark, 0,markRoverY);
addObject(rover, 0,markRoverY);

if you want the combined height of the two objects you will have to store a variable of both heights added and then use that when adding to your world

于 2017-11-30T17:48:22.923 回答