E
Edwin
Guest
Hello, fellas.
I have a small problem with using “for” statement to set all the arrays to 0 by subtracting them while they are not smaller or equal to 0. So when all my arrays are smaller or equal to 0, the object needs to be destroyed. But it does not work as I expected: object is destroying only when one of these arrays are smaller or equal to 0 (may be another reason for this).
Here is my code:
object0:
Create event:
Step event:
Draw event:
If you will compile this project, after pressing enter key you will see that first string disappears and destroying, without waiting for others.
Ask me anything you want to. I will be appreciated by any help.
I have a small problem with using “for” statement to set all the arrays to 0 by subtracting them while they are not smaller or equal to 0. So when all my arrays are smaller or equal to 0, the object needs to be destroyed. But it does not work as I expected: object is destroying only when one of these arrays are smaller or equal to 0 (may be another reason for this).
Here is my code:
object0:
Create event:
Code:
flag = false;
array_string[0] = "Hello.";
array_string[1] = "How are you?";
array_string[2] = "I hope you feel okay right now.";
array_alpha = array_create(array_length_1d(array_string));
for (var i = 0; i < array_length_1d(array_string); i++) {
array_alpha[i] = 1;
}
Code:
if (!flag) {
if (keyboard_check_pressed(vk_enter)) {
flag = !flag;
array_alpha[0] = .5;
}
} else
if (flag) {
for (var i = 0; i < array_length_1d(array_string); i++) {
if (array_alpha[i] > 0) {
array_alpha[i] -= .01;
} else {
instance_destroy(id);
}
}
}
Code:
for (var i = 0; i < array_length_1d(array_string); i++) {
draw_set_alpha(array_alpha[i]);
draw_text(x, y+(i*24), string(array_string[i]));
draw_set_alpha(1);
}
Ask me anything you want to. I will be appreciated by any help.