Hello everybody,
I am trying to get a Hook to interact with an container. So when I press spacebar it moves with the hook. But because they have the same name when spawned. When they cross (the containers) it switches to the oldest container. I tried to solve it like this:
I try to give every object that spawns to have a different name this way.
When I dont change anything to this code, it says that it expects an ] after
When I remove it. Like this:
It says incompatible types highlighting new ContainerOrange line
Any help would be awesome.
Here is the code of the hook, just in case it is usefull.
if(1==1){ for(int i = 0; i<100; i++) { ContainerOrange containerOrange[i] = new ContainerOrange(); addObject(new containerOrange[i], 642+(i*10), 80); } }
ContainerOrange containerOrange[
if(1==1){ for(int i = 0; i<100; i++) { CraneHook containerOrange[] = new ContainerOrange(); addObject(new containerOrange[i], 642+(i*10), 80); } }
if (Greenfoot.isKeyDown("space")&& isTouching(ContainerOrange.class)) { if(liftedContainer==true) { Actor containerorange = getOneIntersectingObject(ContainerOrange.class); containerorange[i].setLocation(getX(),getY()); return; } else { if (Greenfoot.isKeyDown("space")&& isTouching(ContainerOrange.class)) { liftedContainer=true; return; } else { if (Greenfoot.isKeyDown("space")&& isTouching(ContainerOrange.class) && liftedContainer==true) { liftedContainer=false; } } } }