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

2024/1/25

how to make actors move in order?

aabcin aabcin

2024/1/25

#
so i have this 5 lanterns and i want to lit up 3 of them but like in order, like 5-4-2, but when i try to write in code it lit up at the same time
Kyuubi Kyuubi

2024/1/26

#
Try using something like this
for(int i=0; i<=1000; i++){
     if(i==250)lightlantern1;
     if(i==500)lightlantern2;
      
}
and so on this way you have a way to introduce cooldown between lightups. An alternative is using the greenfoot delay function, but that stops the whole act for a few moments
danpost danpost

2024/1/26

#
aabcin wrote...
so i have this 5 lanterns and i want to lit up 3 of them but like in order, like 5-4-2, but when i try to write in code it lit up at the same time
A for loop, as Kyuubi suggests, will not work here. The loop will complete its processing in one act step and all will light up immediately as a result. It would be difficult to provide decent code without seeing what you have to work with. Please provide your Lantern class code. Then, also, provide any code you have outside that class that controls (whether working or not) the lighting/darkening of the lanterns and indicate which class those codes are located in.
You need to login to post a reply.