Disabling Specific Events

Talk about making games.

Disabling Specific Events

Postby Hedfone » Fri Aug 18, 2006 8:58 pm

My game features a ninja who can throw Ninja Stars, but only after having collected them. I need to event disable this event if he has no Stars without disabling EVERY key down event.

How do I do this?
User avatar
Hedfone
 
Posts: 174
Joined: Mon Jul 31, 2006 9:47 pm
Score: 2 Give a positive score

Postby makslane » Fri Aug 18, 2006 9:20 pm

1) Create a actor variable to control the star number (nstars)
2) In the 'Create Actor' event of ninja, put the action 'Event Disable' key down.
3) In the event are using to collect the stars, put:
Code: Select all
nstars++;


And put the action 'Event Enable' key down.

4) In the event are you using to throw the stars put:
Code: Select all
nstars--;
if(nstars <= 0)
{
   EventDisable("Event Actor", EVENTKEYDOWN); //If the event is in ninja actor
   nstars = 0;
}
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby S0L1Dfake » Tue Dec 05, 2006 4:47 am

Makslane, I used that code in my game and it works for stopping the use of the weapon, but when you disable keydown it also stops my character from being able to move ('keydown:right or left') without ammo. I am also having trouble stopping the player from using ammo that is depleted. PLEASE HELP!!!!
User avatar
S0L1Dfake
 
Posts: 15
Joined: Mon Dec 04, 2006 7:31 am
Location: Cleveland, Ohio
Score: 0 Give a positive score

Postby makslane » Tue Dec 05, 2006 11:50 pm

In this case, create an Actor variable to hold the ammo count.
In the Key Down event, put:

if(ammo > 0)
{
//Fire

//Decrease count
ammo--;
}
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron