Page 1 of 2
help with mouse clicks
Posted:
Tue Jun 26, 2007 2:22 pm
by delsol456
how do you make a button that will perform 1 action the first time that you click it, and a different action the 2nd time, and the 3rd time......
also, how do you chage the color of an object when you click on a button?
Posted:
Tue Jun 26, 2007 3:01 pm
by Oman
for your question, i would create a variable (call it var). on create actor put var = 0;
on click put
- Code: Select all
If (var == 0)
{
var = 1;
do stuff;
}
else if (var == 1)
{
var = 2;
do other stuff;
}
and so on....
but, please do not put a subject line like HELP!!!!, but put, "help with mouse clicks", so people know what ur talking about:)
Posted:
Tue Jun 26, 2007 3:02 pm
by metal_pt
Hi!
Maybe if you create a global variable and update it every mouse click.
On create
- Code: Select all
action_nr=0;
On mouse button down
- Code: Select all
if(action_nr==0)
{
//do the code you want
}else
if(action_nr==1)
{
//do the other code you want
}else
if(action_nr==2)... and so on
...
action_nr=action_nr+1;
Hope it helps!
Posted:
Tue Jun 26, 2007 3:04 pm
by Oman
isnt that what i just said?
Posted:
Tue Jun 26, 2007 3:08 pm
by metal_pt
lol
Sorry oman, I have posted it before I noticed you had already posted.
Posted:
Tue Jun 26, 2007 3:12 pm
by Oman
oh.. ok
Posted:
Tue Jun 26, 2007 3:14 pm
by d-soldier
One way would be to use variables. Set up a varibale (actor variable in this case). In the objects create-actor script set the variable to zero.
variable=0;
Then in the key-down event use a script that says:
if (variable==0)
{
insert what you want to do here;
variable=1;
}
if (variable==1)
{
insert what you want to do here;
variable=2;
}
if (variable==2)
{
insert what you want to do here;
variable=0;
}
.. and so on, and so on. Basically this checks the variable, does something, and then makes the varibale (+1) each time...
Also, be sure to make your post subject regarding what the post is about, avoiding the cliche "help me" type titles.
Posted:
Tue Jun 26, 2007 3:14 pm
by d-soldier
Wow... when I started that last one, no one else had written anything...
Posted:
Tue Jun 26, 2007 3:16 pm
by Oman
we are fast typers... lol
Posted:
Tue Jun 26, 2007 4:28 pm
by delsol456
I'm a total noob to this. I keep getting error messages. what do they mean.
pic
Posted:
Tue Jun 26, 2007 6:16 pm
by d-soldier
You didnt make the variable... the errors are because you are trying to access a variable that doesn't exist.
Click up on the "SCRIPT" tab,
then GLOBAL CODE,
then VARIABLES (NOT "variables/functions),
click ADD,
choose a name (dont use "variable", name it something that applies to what you are trying to do.),
change the "Global" button to "Actor",
then click ADD.
You now set up a variable that is unique to each actor, whereas if you left it as "global" the single variable would apply to every actor that used it.
Now of course, you will need to adjust your object's KEY-DOWN event and change the word "VARIABLE" to whatever you named it. Keep in mind that names ARE case-sensitive.
Posted:
Sat Jul 07, 2007 5:45 pm
by delsol456
OK, i got the button to work...kind of.
when I click on it, it performs all of the actions (variable 1, variable 2, etc)
is there a way to make it stop between variables.
Posted:
Sun Jul 08, 2007 12:48 am
by delsol456
bump for help
i need to finish this tonight
Posted:
Sun Jul 08, 2007 3:37 am
by d-soldier
What do you mean "stop between variables"? Explain that AND post the code:
Posted:
Sun Jul 08, 2007 4:27 pm
by delsol456
I just figured it out.
I had to reverse the code
if (variable==2)
{
insert what you want to do here;
variable=3;
}
if (variable==1)
{
insert what you want to do here;
variable=2;
}
if (variable==0)
{
insert what you want to do here;
variable=1;
}