help with mouse clicks

Game Editor comments and discussion.

help with mouse clicks

Postby delsol456 » Tue Jun 26, 2007 2:22 pm

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?
Last edited by delsol456 on Tue Jun 26, 2007 4:04 pm, edited 1 time in total.
delsol456
 
Posts: 10
Joined: Fri Jun 01, 2007 11:15 pm
Score: 0 Give a positive score

Postby Oman » Tue Jun 26, 2007 3:01 pm

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:)
Last edited by Oman on Tue Jun 26, 2007 3:03 pm, edited 1 time in total.
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Postby metal_pt » Tue Jun 26, 2007 3:02 pm

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!
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby Oman » Tue Jun 26, 2007 3:04 pm

isnt that what i just said? :?
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Postby metal_pt » Tue Jun 26, 2007 3:08 pm

lol
Sorry oman, I have posted it before I noticed you had already posted.
]v[eta[_ - Using GE since June, 15 2007
Currently using v1.3.8 Registered
metal_pt
 
Posts: 117
Joined: Sat Jun 16, 2007 12:57 pm
Location: Sintra, Portugal
Score: 2 Give a positive score

Postby Oman » Tue Jun 26, 2007 3:12 pm

oh.. ok :D
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Postby d-soldier » Tue Jun 26, 2007 3:14 pm

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.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby d-soldier » Tue Jun 26, 2007 3:14 pm

Wow... when I started that last one, no one else had written anything... :shock:
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Oman » Tue Jun 26, 2007 3:16 pm

we are fast typers... lol :D
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Postby delsol456 » Tue Jun 26, 2007 4:28 pm

I'm a total noob to this. I keep getting error messages. what do they mean.

pic
delsol456
 
Posts: 10
Joined: Fri Jun 01, 2007 11:15 pm
Score: 0 Give a positive score

Postby d-soldier » Tue Jun 26, 2007 6:16 pm

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.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby delsol456 » Sat Jul 07, 2007 5:45 pm

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.
delsol456
 
Posts: 10
Joined: Fri Jun 01, 2007 11:15 pm
Score: 0 Give a positive score

Postby delsol456 » Sun Jul 08, 2007 12:48 am

bump for help

i need to finish this tonight
delsol456
 
Posts: 10
Joined: Fri Jun 01, 2007 11:15 pm
Score: 0 Give a positive score

Postby d-soldier » Sun Jul 08, 2007 3:37 am

What do you mean "stop between variables"? Explain that AND post the code:
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby delsol456 » Sun Jul 08, 2007 4:27 pm

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;
}
delsol456
 
Posts: 10
Joined: Fri Jun 01, 2007 11:15 pm
Score: 0 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron