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

2013/5/21

Score

1
2
3
4
Gzuzfrk Gzuzfrk

2013/5/22

#
java.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:663) at greenfoot.Actor.getOneIntersectingObject(Actor.java:912) at Alien.soldierHit(Alien.java:129) at Alien.act(Alien.java:36) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.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:663) at greenfoot.Actor.getOneIntersectingObject(Actor.java:912) at Alien.soldierHit(Alien.java:127) at Alien.act(Alien.java:34) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) That's what it is doing now
danpost danpost

2013/5/22

#
Same as before, insert the same line after 'minionHit();' in the act method (same line as before 'minionHit();').
Gzuzfrk Gzuzfrk

2013/5/22

#
ok umm what happens when it say out of memory error?
danpost danpost

2013/5/22

#
You restart the application (to free up the memory) and try to figure out why it happened. Some possibilities include repeatedly creating large images or excessive number of actors.
Gzuzfrk Gzuzfrk

2013/5/22

#
Ok so now everything runs but its not adding the points and it only takes one shot to kill
danpost danpost

2013/5/22

#
Remove the method in the Fireball class that checks for aliens (you have the alien checking for fireballs).
Gzuzfrk Gzuzfrk

2013/5/22

#
haha I got it I just went around a few things :D Thanks for all the help man I really appreciate it
Gzuzfrk Gzuzfrk

2013/5/22

#
 private void spawnAlien()  
{  
    int rand = Greenfoot.getRandomNumber(150);  
    if (rand >=3) return;  
    
    if (rand == 0) addObject(new Alien(), 870, 453);  
   
}  
one more how do you make that increase over time?
danpost danpost

2013/5/22

#
private int timer;
private int chance = 150;

private void spawnAlien()
{
    timer = (timer+1)%1500;
    if (timer == 0) chance = chance-10;
    if (rand >= 3) return;
    // etc.
danpost danpost

2013/5/22

#
I missed a line of the code:
private int timer;
private int chance = 150;

private void spawnAlien()
{
    timer = (timer+1)%1500;
    if (timer == 0) chance = chance-10;
    int rand = Greenfoot.getRandomNumber(chance); // double check this line
    if (rand >= 3) return;
    // etc.
Gzuzfrk Gzuzfrk

2013/5/22

#
Where do i put the add object method?
danpost danpost

2013/5/22

#
The code would continue (at line 10) with
if (rand == 0) addObject(new Alien(), 870, 453);
Gzuzfrk Gzuzfrk

2013/5/22

#
private int timer;
private int chance = 500;

private void spawnAlien()
{
    timer = (timer+1)%1500;
    if (timer == 0) chance = chance-10;
    int rand = Greenfoot.getRandomNumber(chance); 
    if (rand >= 3) return;
    if (rand >= 0);
    addObject(new Alien(), 905, 453);
}
This is my code right now and it doesnt look like it works
danpost danpost

2013/5/22

#
It would take a while to see any progress, starting 'chance' at such a high number. Put it back around 100 to 150 and you will probably see that it does work.
Gzuzfrk Gzuzfrk

2013/5/22

#
Alright and with a move method how do you increase the speed of the alien over time?
There are more replies on the next page.
1
2
3
4