This site requires JavaScript, please enable it in your browser!
Greenfoot back
Just_in
Just_in wrote ...

2021/2/26

If touching.class

Just_in Just_in

2021/2/26

#
     if (isTouching(teleporter.class))
      {
    setMainActor(new Wombat(), 250, 300); // the int parameters are centered window x and y ranges
        // to start the main actor elsewhere
        mainActor.setLocation(-220, 50);
}
I dont know why isTouching is a mistake in the code. I have got the teleporter.class and I got a Wombat.class But there stands cannot find symbol...Help pls
danpost danpost

2021/2/26

#
Just_in wrote...
<< Code Omitted >> I dont know why isTouching is a mistake in the code.
Using isTouching would be a problem if you tried to use it in a World subclass.
Just_in Just_in

2021/3/1

#
Oh :) Thank you very much
Just_in Just_in

2021/3/1

#
No, it still doesnt work...I put it into the wombat.class and SetMainactor is wrong.
danpost danpost

2021/3/1

#
The setMainActor method sounds like a ScrollWorrld method. Maybe the code should be:
Actor wombat = new Wombat();
((ScrollWorld)getWorld()).setMainActor(wombat, 250, 300);
wombat.setLocation(-220, 50);
Just_in Just_in

2021/3/2

#
Yes, thank you, now it works
You need to login to post a reply.