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

2020/10/11

Check collision before adding

1
2
3
4
5
Roshan123 Roshan123

2020/10/18

#
Its not adding when b is empty
Roshan123 Roshan123

2020/10/18

#
'i' is not increasing
danpost danpost

2020/10/18

#
At line 35, put:
System.out.print("I");
Run and reply back terminal output when team tries to be re-entered.
Roshan123 Roshan123

2020/10/19

#
Now its working
public void act() 
    {
        addedToWorld(getWorld());
 
    }
    protected void add(World w)
    {
     int i=0;    while(getOneIntersectingObject(null)!=null && i++<m)
     {
         setLocation((int)(Math.random()*w.getWidth()), (int)(Math.random()*w.getHeight()));
      System.ou.println("5161");
     }
     if(i>=m)
     {
         w.removeObject(this);
    }
    }
Roshan123 Roshan123

2020/10/19

#
But it gets removed when it intersects with any class I want this only in the adding time(to check collision) And not for the whole period of time
danpost danpost

2020/10/19

#
Roshan123 wrote...
Now its working
public void act() 
{
    addedToWorld(getWorld());
}
Remove line 3 here. The addedToWorld method is automatically called by greenfoot when an actor is placed into a world.
Roshan123 Roshan123

2020/10/19

#
danpost wrote...
Roshan123 wrote...
Now its working
public void act() 
{
    addedToWorld(getWorld());
}
Remove line 3 here. The addedToWorld method is automatically called by greenfoot when an actor is placed into a world.
But if i will remove then its not working
Roshan123 Roshan123

2020/10/19

#
Can u plz tell me that is their any way to fix it or i have to forget about it.....ಠ﹏ಠ
danpost danpost

2020/10/19

#
Roshan123 wrote...
Can u plz tell me that is their any way to fix it or i have to forget about it.....ಠ﹏ಠ
Is the B actor touching a Tank actor (at all times)?
Roshan123 Roshan123

2020/10/19

#
danpost wrote...
Roshan123 wrote...
Can u plz tell me that is their any way to fix it or i have to forget about it.....ಠ﹏ಠ
Is the B actor touching a Tank actor (at all times)?
Nope....
danpost danpost

2020/10/19

#
Roshan123 wrote...
<< Quote Omitted >> But if i will remove then its not working
Show code you say does not work (as I suggested, with the removal) -- entire B class.
danpost danpost

2020/10/19

#
Roshan123 wrote...
<< Quote Omitted >> Nope....
Why are you removing a touching tank along with b when health goes to zero?
Roshan123 Roshan123

2020/10/19

#
Ohh sorry that code doesn't implement in the app I wrote another mechanism and i forgot to remove that mechanism
Roshan123 Roshan123

2020/10/19

#
I will post the whole scenario source code after some hrs...plz wait for few hrs
Roshan123 Roshan123

2020/10/19

#
Roshan123 wrote...
Ohh sorry that code doesn't implement in the app I wrote another mechanism and i forgot to remove that mechanism
Note line 70 to 92 in b.class (its the another mechanism and the touching mechanism which u r telling about....it doesn't work....i forgot to remove it)
There are more replies on the next page.
1
2
3
4
5