# \[MX\] plz help!

**URL:** <https://forum.kirupa.com/t/mx-plz-help/13646>\
**Category:** Uncategorized\
**Created:** [February 16, 2003, 4:15am UTC](https://forum.kirupa.com/t/mx-plz-help/13646 "2003-02-16T04:15:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![zylum](https://avatars.discourse-cdn.com/v4/letter/z/d26b3c/32.png) [@zylum](https://forum.kirupa.com/u/zylum)\
**Post date:** [February 16, 2003, 4:15am UTC](https://forum.kirupa.com/t/mx-plz-help/13646/1 "2003-02-16T04:15:59Z")

</div>

Hi,

I have just read the tut on the shooting aspect of games and i tried it for myself. I altered it so that you shoot on the x axis and you shoot when the space button is pressed.

My question is, how do you make the bullets shoot when the space button is releases? And or can make the bullet shoot at an interval of one second or so when the space is pressed… The bullets for me are shooting at a continuous streem and that may be a too great advantage for a user…

Any help would be great, Thanks…

-n00bFlasher

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 16, 2003, 7:31am UTC](https://forum.kirupa.com/t/mx-plz-help/13646/2 "2003-02-16T07:31:55Z")

</div>

Well now… Let’s see… You just do this and that and exit everything out and BAM it’s done…

Actually set up some sort of timer… And then every second… Allow the perosn to shoot or the such…

if(spacebar is pressed && timer is at 0)  
{  
SHOOT!;  
}

Got it?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 16, 2003, 8:13am UTC](https://forum.kirupa.com/t/mx-plz-help/13646/3 "2003-02-16T08:13:55Z")

</div>

Or, create a function and use setInterval() to call it…

```auto
function shootBullet()
{
     // your shooting tween or animation goes here //
}

shootInterval = setInterval(shootBullet, 1000);
// this runs shootBullet() function in every 1 second...

```

Chech out the Flash manual or search the forum for more information on setInterval()/clearInterval() functions…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 16, 2003, 6:33pm UTC](https://forum.kirupa.com/t/mx-plz-help/13646/4 "2003-02-16T18:33:12Z")

</div>

Thanks for the help guys 😛 i’ll try it out… Thanks again!

- n00bFlasher

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 16, 2003, 6:45pm UTC](https://forum.kirupa.com/t/mx-plz-help/13646/5 "2003-02-16T18:45:08Z")

</div>

Uhh, hi,

i tried your way first CyanBlue but it doesn’t really work. when the space bar is pressed, it takes one second before the bullets start shooting in a stream rather than shooting a bullet everysecond. Maybe I’m doing something wrong… where you said to place the tween or animation i put the AS where it tells the bullet to shoot…:q:

And playamarz, I don’t really understand how to set up a timer… If you can slowly walk me through it, that would be really helpful. Thanks again…(-:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 16, 2003, 11:52pm UTC](https://forum.kirupa.com/t/mx-plz-help/13646/6 "2003-02-16T23:52:51Z")

</div>

Set up a couple of variables…

secTimer = # in seconds  
framePerSec = The current fps your movie is set to  
shotTimer = secTimer \* framePerSec;

Then… Everytime a frame is loaded…

shotTimer–;

When shotTimer is to 0… Then it’s been that many seconds.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 17, 2003, 6:43am UTC](https://forum.kirupa.com/t/mx-plz-help/13646/7 "2003-02-17T06:43:34Z")

</div>

Yup… I know what that is… It takes that much of time to start one cycle with setInterval()… Don’t know why that is behaving like that… I just call the function one time and then do the setInterval afterwards…

```auto
shootBullet();
shootInterval = setInterval(shootBullet, 1000);

```

That does the job for me… 😃 playamarz’s timer shouldn’t be that hard to implement too…
