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

2020/1/21

what is wrong wit my code?

SanjiNaha SanjiNaha

2020/1/21

#
/** * Act - do whatever the Ball wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move(10); dissapear(); } public void dissapear() { if(isAtEdge()) { World MyWorld = getWorld(); MyWorld.removeObject(this); } else if(isTouching(Pxl2.class)) { World MyWorld = getWorld(); MyWorld.removeObject(this); } else if(isTouching(Ball2.class)) { World MyWorld = getWorld(); MyWorld.removeObject(this); } } }
danpost danpost

2020/1/21

#
SanjiNaha wrote...
<< Code Omitted >>
I do not know. Nothing appears to be wrong with what is given. Are you getting an error? If so ... what? Or, is it just not doing what you want? If so, what do you want to happen and what is happening that you do not want?
SanjiNaha SanjiNaha

2020/1/21

#
it tells me that t there is a problem when my character makes two fireballs explode and when they bump it gives me an error, not a syntax error tho
danpost danpost

2020/1/21

#
SanjiNaha wrote...
it tells me that t there is a problem when my character makes two fireballs explode and when they bump it gives me an error, not a syntax error tho
A run-time error, then. What text is output to the terminal window?
SanjiNaha SanjiNaha

2020/1/21

#
ava.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:713) at greenfoot.Actor.isTouching(Actor.java:978) at Ball2.dis(Ball2.java:37) at Ball2.dissapear(Ball2.java:33) at Ball2.act(Ball2.java:18)
danpost danpost

2020/1/22

#
SanjiNaha wrote...
<< Error Trace Omitted >>
That error was not produced with the code given above. What is your revised code that this came from?
You need to login to post a reply.