jaz
July 22nd, 2004, 08:24 AM
Hi fellow Kirupians,
I'm trying to build a simple game:
You have 3 objects in a room and a "submit" button, lets say the objects are lightbulbs - you can (toggle) switch each lightbulb on or off, by clicking on them. (As many times as you like, and in any order you like).
When you hit the "submit" button, if all the lights are ON - you win, but if ANY of the lights are OFF - you lose.
Simple huh?
At the moment I am failing to get my head round how to do this! - I'm setting a variable for each light, either on or off:
lightOne = "on"
but I can't make the code on the "submit" button react to what the variables are:
on (release) {
if (lightOne == "on") {
gotoAndStop("win");
} else {
gotoAndStop("lose");
}
}
Of course, this is only for one lightbulb, I also need to put in the code that will allow you to switch on more than one, and in no particular order.
Perhaps string variables is the wrong approach, maybe I should be using booleans...
A little help please?
jaz :h:
I'm trying to build a simple game:
You have 3 objects in a room and a "submit" button, lets say the objects are lightbulbs - you can (toggle) switch each lightbulb on or off, by clicking on them. (As many times as you like, and in any order you like).
When you hit the "submit" button, if all the lights are ON - you win, but if ANY of the lights are OFF - you lose.
Simple huh?
At the moment I am failing to get my head round how to do this! - I'm setting a variable for each light, either on or off:
lightOne = "on"
but I can't make the code on the "submit" button react to what the variables are:
on (release) {
if (lightOne == "on") {
gotoAndStop("win");
} else {
gotoAndStop("lose");
}
}
Of course, this is only for one lightbulb, I also need to put in the code that will allow you to switch on more than one, and in no particular order.
Perhaps string variables is the wrong approach, maybe I should be using booleans...
A little help please?
jaz :h: