Mouse Button Down scripting help

Game Editor comments and discussion.

Mouse Button Down scripting help

Postby Irondan75 » Wed Apr 06, 2011 6:16 pm

I have a game with on screen buttons. My FIRE button is supposed to fire only ONE shot per press with the Mouse Button Down Event
but it fires multiple shots with each press. I have MBD set to shoto=1; and MBU to shoto=0;

Am I missing a variable/function or is it script?

I'd like the FIRE button to only shoot one bullet per click.
Irondan75
 
Posts: 22
Joined: Thu Mar 10, 2011 12:10 pm
Score: 0 Give a positive score

Re: Mouse Button Down scripting help

Postby AnarchCassius » Wed Apr 06, 2011 6:44 pm

I think I know the problem. What is testing for shoto? A timer on the player? Basically once you press mouse down shoto is going to stay 1 until you release the mouse. So if you just check for shoto it will keep firing. In your fire code try setting shoto to 0 once the shot is fired, then the player will have to mouse up (setting it 0, no effect) and mouse down again (setting it back to 1) to fire again.
AnarchCassius
 
Posts: 55
Joined: Sat Jan 29, 2011 1:33 am
Score: 6 Give a positive score

Re: Mouse Button Down scripting help

Postby Irondan75 » Wed Apr 06, 2011 9:12 pm

Thanks Anarchcassius for the suggestion, but I tried what you said and it didnt work.

I have two events on my button actor, mouse button down shoto=1; and mouse button up shoto=0;

I have one event on my player actor, Draw Actor with this script:
if(righto==1)
x=x+8;
if(lefto==1)
x=x-8;
if(shoto==1)CreateActor("RedRocket", "Rocket red_edited-1", "(none)", "(none)", 0, 0, false);
if(shoto==2)CreateActor("GreenRocket", "Rocket green_edited-1", "(none)", "(none)", 0, 0, false);
if(shoto==3)CreateActor("YellowRocket", "Rocket yellow_edited-1", "(none)", "(none)", 0, 0, false);

Currently when I press the FIRE button my player shoots the rockets, but I need the FIRE button set on a toggle, like pressing it once fires one bullet actor
and when released it resets so it can be pressed again for another bullet...like a semi auto gun, not the full auto I have now :lol:
Irondan75
 
Posts: 22
Joined: Thu Mar 10, 2011 12:10 pm
Score: 0 Give a positive score

Re: Mouse Button Down scripting help

Postby Game A Gogo » Wed Apr 06, 2011 9:18 pm

Code: Select all
if(shoto==1){CreateActor("RedRocket", "Rocket red_edited-1", "(none)", "(none)", 0, 0, false);shoto=0;}
if(shoto==2){CreateActor("GreenRocket", "Rocket green_edited-1", "(none)", "(none)", 0, 0, false);shoto=0;}
if(shoto==3){CreateActor("YellowRocket", "Rocket yellow_edited-1", "(none)", "(none)", 0, 0, false);shoto=0;}


replace the same bit of code... and it should work. Also your mouse button up is useless now if its only to change shoto to 0
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Mouse Button Down scripting help

Postby Irondan75 » Wed Apr 06, 2011 10:08 pm

THANK YOU Game A Gogo....You have solved my issue!! +1 to you for a speedy resolution :D
Irondan75
 
Posts: 22
Joined: Thu Mar 10, 2011 12:10 pm
Score: 0 Give a positive score

Re: Mouse Button Down scripting help

Postby AnarchCassius » Wed Apr 06, 2011 10:16 pm

You must have misunderstood or coded it wrong because that IS what I said to do. :)
AnarchCassius
 
Posts: 55
Joined: Sat Jan 29, 2011 1:33 am
Score: 6 Give a positive score

Re: Mouse Button Down scripting help

Postby Irondan75 » Wed Apr 06, 2011 11:22 pm

My apologies Anarchcassius, I just re read your 1st reply and I do see thats what you meant.
I guess I just needed to see it written out for me to understand :lol:
Anyway +1 to you for your help and for cutting me some slack for being a bit slow :oops:
Irondan75
 
Posts: 22
Joined: Thu Mar 10, 2011 12:10 pm
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron