I'm making a scrolling game and improvising my own codes based on some ideas I've learned some time ago. What I'm trying to do is make
count keep increasing by ones until it is equal to 27, then when it is equal to 27 start to decrease by ones until it reaches 0 again. I want this to continue in a never-ending cycle. At first I tried:
if (count = 0) {
count += 1;
} else
if (count = 27) {
count -= 1;
}
- if (count = 0) {
- count += 1;
- } else
- if (count = 27) {
- count -= 1;
- }
When that didn't work, I tried:
count += num;
if (count = 0) {
num = 1;
} else
if (count = 27) {
num = -1;
}
- count += num;
- if (count = 0) {
- num = 1;
- } else
- if (count = 27) {
- num = -1;
- }
Neither of these worked, I traced
count and it stayed at 27 - I'm thinking it's because the first count+=1 was not cancelled before the count-=1 was applied (for the first try at the code). I honestly have no clue about the second try at the code, and no idea on how to fix this problem (and trust me I've tried).
So, does anyone know a system that can make
count bounce between 0 and 27 without getting stuck, or even a way to cancel the count+=1 when count-=1 is introduced? I'm still on my way to becoming fluent in actionscript, so any help would be very much appreciated. Thanks in advance to anyone willing to help
