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

3 days ago

something not working

Alizee Alizee

3 days ago

#
my code doesn't repeat like i code it to if (attaqueChoisi == 3){ while(repAttaque3 < 10){ prochaineAttaque = System.currentTimeMillis(); if(prochaineAttaque >= derniereAttaque + 300){ derniereAttaque = prochaineAttaque; getWorld().addObject(new ProjectileBoss1(),getX(), getY()); repAttaque3++; } } }
danpost danpost

2 days ago

#
Alizee wrote...
my code doesn't repeat like i code it to << Code Omitted >>
You are using a while loop, which must complete within a single act cycle. Therefore, it's a cover-up -- it does repeat !!! (probably) I believe that all ProjectileBoss1 instances happen to be exactly on top of each other (covering each other up). It might be easier to just use a counter to count act steps instead of the system timer:
private int repAttaque3;

public void act() {
    //  starting attack
    if (attaqueChoisi == 3) {
        int delay = 300;
        int reps = 10
        repAttaque3 = delay*(reps-1)+1;
    }
    
    // continuing attack
    if (repAttaque3 > 0 && --repAttaque3%300 == 0) {
        getWorld().addObject(new ProjectileBoss1(), getX(), getY());
    }
}
The repAttaque3 counter will hit a multiple of 300 ten times while counting down to zero.
Alizee Alizee

2 days ago

#
I tryed the code you send me but the delay doesn't work they appen all at the same time;
Alizee Alizee

2 days ago

#
it might be because attaqueChoisi doesn't change so it start the attack every frame
danpost danpost

yesterday

#
Alizee wrote...
it might be because attaqueChoisi doesn't change so it start the attack every frame
Please provide the complete class codes to your world and this characters class.
You need to login to post a reply.