Pausa nos tiros

Non-platform specific questions.

Pausa nos tiros

Postby luizluizhenriqu » Tue Jan 03, 2012 5:00 pm

Hi! I'm creating a shooter game, so far so good I can make the basic weapons such as pistols and shoot machine guns and shotguns and plan to put automatic weapons lesers not here comes the problem can not I make a pause time between one shot and other, already tried everything and tired to create time and I am newbie! please help me!
luizluizhenriqu
 
Posts: 1
Joined: Sat Apr 02, 2011 3:13 pm
Score: 0 Give a positive score

Re: Pausa nos tiros

Postby skydereign » Tue Jan 03, 2012 6:58 pm

Well, you can use a variable to create a pause in between the shots fired. So you'll need to declare a variable, in this case I'll call it bullet_timer. If you don't know how to declare a variable, the easiest way is to go to global code and add this script.
Global Code
Code: Select all
int bullet_timer;

int is the variable type (meaning it only stores integer values) and bullet_timer is the name of the variable. Anyway, if you have space as your shooting event, you can do something like this.
player -> Key Down Space (repeat enabled) -> Script Editor
Code: Select all
bullet_timer++;
if(bullet_timer>=2)
{
    // replace this line with your CreateActor bullet function call
    bullet_timer=0;
}

This will make the player fire a bullet every other frame. You can increase the 2 to decrease the frequency of bullet fire.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest