ActionScript 2.0 :: Firing One Bullet Per (Space Key) Press

Jul 27, 2004

I am just testing some stuff, and everytime the space key is pressed I want one bullet to come out, however righty now you can just hold down space and it keeps firing...here's the code i used :
on (keyPress "<Space>") {
i = i+1;
duplicateMovieClip(_root.bullet, "bullet"+i, i);
}

View 11 Replies


Similar Posts:


ActionScript 3.0 :: Shooting Multiple Bullets - Press The Space Bar The First Bullet Disappears And The Bullet Animation Starts Again

Nov 24, 2008

I'm trying to make my platform game character shoot a gun, my character and gun are one movieclip and the bullet is another. The bullet mc starts on a blank frame with a stop() function, when I press the space bar the bullet mc plays from frame 2 which is a motion tween of the bullet quickly moving across the page. I've set the bullet's y and x values relative to the character mc so that the bullet always comes from the gun.

My issue is that if I press the space bar a bullet will fly out of the gun (great!) but if I press the space bar again, the first bullet disappears and the bullet animation starts again. I want to be able to shoot a new bullet every time I press the space bar without effecting the bullets that have already been shot.

[Code]....

View 3 Replies

ActionScript 2.0 :: Firing One Bullet Per Press

Jul 27, 2004

im just testing some stuff, and everytime the space key is pressed i want one bullet to come out, however righty now you can just hold down space and it keeps firing...heres the code i used [code]

View 11 Replies

ActionScript 2.0 :: Firing One Bullet Per Press?

Jan 28, 2011

i have a slight problem, im just testing some stuff, and everytime the space key is pressed i want one bullet to come out, however righty now you can just hold down space and it keeps firing...heres the code i used :

on (keyPress "<Space>") {
i = i+1;
duplicateMovieClip(_root.bullet, "bullet"+i, i);
}

View 1 Replies

ActionScript 3.0 :: Button Firing Off Multiple Times On Quick Press Only

Sep 11, 2011

i wrote this code:

[Code]...

} // end btn4Loaded. and it works, once clicked, it does what it has to do. Ofcourse, me trying to break it, i found that if i click the buttons fast, it will re-import the external swfs causing me to have multiple instances of the external swf. so in short, if i click like normal(slow ) ie like a person that clicked to view a section etc, then its fine, if i click fast or repeated clicking ie like a person that double clicks etc, then the problem occurs.

View 2 Replies

ActionScript 2.0 :: Make On Key A - Press A Instead Of Space?

May 24, 2004

This is a code that I have on a movie clip:

onClipEvent(enterFrame){
if (Key.isDown(Key.SPACE)){
_root.acc = 2;[code]....

How do I make on key A - so you can press A instead of Space?

View 3 Replies

ActionScript 3.0 :: Press Space Bar And Create A Line?

May 7, 2010

How would I go about creating a function where, when the space bar is pressed and held down it creates a continual line (that flows until you release the space bar)

View 3 Replies

ActionScript 2.0 :: Increase Var Everytime Press Space?

Feb 17, 2009

I have a var defined and that is colour var colour = 0; and I want to increase var everytime you press space so I have an invisible button with this code in it

on (keyPress "<Space>") {
colour+1;
}

This is so that I can advance in a movieclip. I have the code for that here:

onEnterFrame; {
if (colour == 1) {
head.gotoAndStop(1);
}

[Code].....

View 5 Replies

ActionScript 3.0 :: Flash New Game - Set Up The Key Press And Know Space Is 32?

Jul 14, 2010

I am currently working on a new game and I need help on this part. It is probably simple to do but I am a noob. Basically I am making a window cleaning game and I have set it up so that the dirt slowly dissapears through the frames. What I need to know is how to I script it so that each time I press space it jumps to each frame.

e.g hit space jump to frame 2 press again jumps to next frame.I know How to set up the key press and know space is 32..

View 4 Replies

ActionScript 3.0 :: Press Space Bar To Launch Some Missiles Up The Screen?

Oct 19, 2010

I press space bar to launch some missiles up the screen.My code works it is just I cant fire 1 missile at a time because pressing space bar to fire , then 2-3 missiles go at once.
//main

Code:I press space bar to launch some missiles up the screen.My code works it is just I cant fire 1 missile at a time because pressing space bar to fire , then 2-3 missiles go at once.

/main
if (dict[Keyboard.SPACE]==true ) {
myplayer.firemissile(mybackList); [code].....

View 2 Replies

ActionScript 3.0 :: Setup Bullet Factory/bullet Switch For The Same Player Object?

Mar 25, 2011

I'm currently making my own shoot'em up game where the player can switch  between two player types which will fire their own bullet type in this  case, squares and circles. I've setup the player switch function via  pressing "space" button (switching between the two player types) and the  default bullet type is "squares" and I'm not sure to approach the  coding with changing the bullet type to "circles".I've written 2 classes for the bullet and player setup:Player Class: Creates instance of bullet on screen and enables the switch player type function

Bullet Class: Enables bullet properies and bullet types Player Class: Code:function onKeyDown(event:KeyboardEvent):void {if (event.keyCode == 32) //// pressing/holding "space bar" to function

[code]....

View 5 Replies

ActionScript 3.0 :: Stage - KeyboardEvent - When The Game Ends And I Press Restart, The SPACE Key Is Not Working?

Dec 17, 2009

The problem is: when the game starts, "SPACE BAR" is working fine and changes the game from day to night. When the game ends and I press restart, the SPACE key is not working. On the third time it works, on the fourth not and it follows that way. Every second time that I play the game, the SPACE key doesn't work.

The game initializes the player and sends him as a parameter a stage object and the player listens for KEY_UP.When I press restart, the game runs the init() function again.Below there are the Game.as and Player.as classes.

Code:
package
{
import com.greensock.TweenLite;[code].....

View 2 Replies

ActionScript 3.0 :: Set The Bullet.x To Ship.x In The Bullet Class?

Oct 4, 2009

i have 2 classes, one for ship one for bullet.i was trying to set the bullet.x to ship.x in the bullet class but it keeps telling me undefined. but clearly it is in my ship class.

View 10 Replies

ActionScript 1/2 :: Tetris Game - Block Go Directly To The Bottom On The Press Of "space"?

Apr 10, 2010

I'm using AS2 and fps120.I'm creating a tetris game, but I encountered a problem: I made a function which makes the block go directly to the bottom on the press of "space".I used

if(Key.isDown(Key.SPACE)){
...
}

But when I pressed space, the blocks stacked up immediately. It's because after I press space, another block apears immediately and goes to the bottom immediately, and keeps going until I release spade. It isn't a problem if I use lower fps, but my fps is 120, which means even I release space as quickly as I could, at least six blocks would stack up. I want to know is there anyway to detect the releasing of "space" or a detection which only detects on the instant I press, instead of when the key is down.

View 3 Replies

Actionscript 3 :: Flex Alert Control: Activating The "default" Button On Enter/space Key-press?

Dec 17, 2009

No matter what I try, I can't seem to fire the click event on the "default" button in an Alert control in a Flex 3.4 application.

[Code]...

View 1 Replies

ActionScript 2.0 :: When Press A Button Mc Starts A Countdown But Every Other Press Doesn’t Reset It?

Jan 13, 2009

How can i make it so a when you press a button it starts a countdown but every other press dosent reset it?

View 14 Replies

ActionScript 3.0 :: Combine One Tab Press And Continuously Press On Keyboard

Mar 13, 2010

I have a problem when I making a game Flash with action script 3,. I want tomake my character move when the key helding and I want  my character attackwith one tab press either

View 3 Replies

ActionScript 1/2 :: Press +1 Text Increases By One, And When Press -1 It Decreses

Aug 29, 2011

I have text field which is 0 by default (score_txt)Two buttons +1 and -1 (plus_btn and minus_btn) When I press +1 text increases by one, and when i press -1 it decreses

View 4 Replies

CS3 Dynamic Textbox Bullet Bug

Apr 22, 2009

I've been working with Flash for over 3 years, but I can't figure this one out. I've got a body of text, half of which are bulleted points designated by <li></li>. It's loaded into a html-ised dynamic textbox.

[Code]....

It displays fine as is. However, if I make the box selectable, and select any part of the bulleted list, the ENTIRE body of text turns into a giant bulleted list, including the non-bulleted portion at the beginning. I've managed to replicate this bug with Flash 8 and CS3, using a variety of flas made from scratch.

View 1 Replies

ActionScript 2.0 :: Bullet Is Not Starting From The Car?

Nov 26, 2010

I'm creating a small car game where you shoot from the car, so I've made a bullet animation with this code inside the mocieclip:

Actionscript Code:
shellNo = 0;function shellEject(){shell_holder.attachMovie("shellAnim", shellNo, shellNo);shellNo++;}

But the problem is that the car is moving when you controll it so the bullet stays on the same position and I want it to follow the car and start from the same position as the car whereever it goes.

View 1 Replies

ActionScript 1/2 :: Bullet Is Not Starting From The Car

Nov 25, 2010

I'm creating a small car game where you shoot from the car, so I've made a bullet animation with this code inside the mocieclip:

shellNo = 0;
function shellEject(){
shell_holder.attachMovie("shellAnim", shellNo, shellNo);
shellNo++;
}

But the problem is that the car is moving when you controll it so the bullet stays on the same position and I want it to follow the car and start from the side of it whereever it goes.

View 1 Replies

IDE :: <br> Within <li> Creating New Bullet Point?

Mar 17, 2009

I have some code in for a dynamic text field:

<ul><li>Item one</li>
<li>Item two line one<br>Item two line two</li>
<li>Item three</li></ul>

[code].....

View 3 Replies

ActionScript 2.0 :: Bullet Is Not Starting From The Car

Nov 26, 2010

I'm creating a small car game where you shoot from the car, so I've made a bullet animation with this code inside the mocieclip:

[Code]...

But the problem is that the car is moving when you controll it so the bullet stays on the same position and I want it to follow the car and start from the same position as the car whereever it goes.

View 1 Replies

Way To Remove 'Enemy' When It Comes Into Contact With 'bullet'

Jan 18, 2010

Basically i just need a simple way to remove the "Enemy" when it comes into contact with "bullet".Ive been looking on the internet but its just really confusing me at the moment. And im not sure how easy its gonna be with the way i have set it up.

View 1 Replies

ActionScript 1/2 :: How To Add Bullet Points To TextField

Sep 21, 2010

I've made a scrollable text field with the UIScrollBar component. Now I need bullet points in that text. How do I create them?

View 1 Replies

Flash :: Program The Path Of A Bullet?

Nov 8, 2010

I am playing around with ActionScript 3 and trying to build a very simple prototype for a video game (top-down action/shooter) and realized that handling bullets is a little bit more challenging than I originally imagined.

In order to get a fairly decent "flight" of the bullet between the character and the target, I ended up using a highly modified version of Bresenham's Line Algorithm to determine the flight path of the bullet and then merely draw a tiny flash.geom.Rectangle object at the appropriate place on that "flight path" during the draw-frame stage of my application.

I haven't noticed any real problems, but I just can't imagine this being the best way to handle bullets in a Flash game. I imagine that once there are multiple enemy players on the screen and lots of bullets flying around (especially once I code in automatic weapons) that things could come grinding to a halt.

What am I missing here? I'm not really a game developer and so most of the things I'm doing I've just "made up" on the spot, but I can't figure out how to effectively handle bullets in Flash.

EDIT: As requested, here is "my" Bresenham code. I say "my" in quotes, because I basically ripped this from somewhere on the internet. My changes to the algorithm basically involve the lines at the bottom. The original implementation would find the path from player character to the target, except that every once in a while (and I wasted a little bit of time trying to figure this out but never got anywhere) it will generate the path from the target to the player. To "fix" this, I ended up just checking the first X/Y values from the path array and reversing the array if those values didn't match the X/Y values of my player character.

[Code]...

View 4 Replies

ActionScript 2.0 :: Bullet Holes With A Lifespan?

Jul 29, 2005

I am trying to create a bullet hole effect when you click the mouse down.I want a bullet hole to appear where you click the mouse and to stay there, and then when you have > 10 bullet holes on the stage i want to earliest ones to start to fade out.

Here is my code so far:

[AS]
onClipEvent (mouseDown) {
i++;
this.duplicateMovieClip("BulletHole"+i, i+1);

[code]...

However this just duplicates the movie clip and then when you click again it disapears straight away.

View 12 Replies

ActionScript 2.0 :: Collision Between Bullet And Monster?

Jan 11, 2011

i just made a 2d shooting game lately. I got a question, how do you make a collision between the bullet and the monters? Here's my code:

Code:
enemy_mc.onEnterFrame = function ()
{
if (bullet_mc.hitTest(this._x, this._y, true)) [code]...

But it doesn't seem to destroy/remove the monster when it hits or even say 'true' on the text on the upper left corner.

View 2 Replies

ActionScript 2.0 :: Press Start Drag On Press Stop Drag?

Jun 17, 2005

i have an object that i want to drag and drop with the same event.Something like on press start drag and on press again stop drag. I'm sure it's pretty simple with and if and else statment but i can't find how to do that...The best i have done so far was this:

[Code]...

View 4 Replies

Make An Enemy Bullet Go Towards The Main Character?

Oct 12, 2008

How would i make an enemy bullet go towards the main character?

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved