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.
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.
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.
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
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.
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.
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.
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.
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.
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]
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.
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); }
So the problem is basicly this: It all works just fine, but when the bullet hits the target it gets destroyed (this is ok) but also any bullet that was shoot before it (meaning also: with a lower y) gets destroyed aswell wich is anoying. Here's the code (left the comments so you can find your way around easier)
Code: stop();//add a stop function too! enemyspeed =1 life=3 var gameOver:Boolean = false;
I have added some bullet points in dynamic text but the gap between each one is massive, how can I get it so they are directly under each other.I am using the tag <li>
I am trying to program a game and I want the enemy character to fire a bullet every second, but instead he is firing an infinite amount of bullets right after the other. Here's the code with the timer:
if (k == 0){ var shootRight1 = new Timer(1000,1); shootRight1.addEventListener(TimerEvent.TIMER_COMPLETE, enemy1shoot); shootRight1.start();
I found a tutorial on the internet and have begun toying with it. I figured out what all the segments did and how they worked and effected the game (mostly through trial and error...) once i figured out what EXACTLY i had i started making changes.
-What i want - once the bullet hits a monster OR goes out side of the range of the gun it disappears and another shot can be fired (which is done automatically via my script no user input needed)
-What i have - when the bullet goes off the page (x>550, x<0, Y>400, Y<0) it disappears and another shot can be fired... obviously this is problematic to game play...
Take a look at this scenario, I have two characters, one shoots two bullets on the direction of the other character, the bullets are fired instantly and travel at infinity speed, how to detect a collision? Here's an image to illustrate the problem: The red bullet would clearly miss, but the green bullet would hit, how to perform this kind of collision test?
My goal is to shoot a bullet everytime I click on ship. What happens, in fact, is that If I click on it once, the bullet is shot, but if I click on it twice before the first bullet is off the screen, the first bullet literally stops(it does not disappear, only stops) and the second bullet is shot.
public var ship:Ship = new Ship(); public var bullet:Bullet = new Bullet(); stage.addChild(ship);[code]...
I'm working on a side scroller that has a character that fires a bullet every time you hit spacebar, the problem I'm having is moving the bullet in the direction the character is facing (left or right).
I have a few of boolean variables to tell me which direction my character is facing: walkingRight | walkingLeft, so if my walkingRight == true, I want the bullet to travel +=10, and walkingLeft == true, bullet -= 10.
The problem is, when I fire facing left, the bullet moves left, but as soon as I turn right, that same bullets starts moving right.
Here is a snippet of AS3 code (Every Frame):
if(gamepad.fire2.isPressed){ // initiate bullet var bullet = new Bullet();
[URL], but this is a completely different question. I now have a fully functionnal jet plane which fires tiny red bullets. Now, I want to be able to alternate between bullet/ammo types on the fly, (with a shortcut like shift or something, but not neceserilly that) from the red bullet to something like a yellow laser. I'll attach the file I have up to now.
how i can make a collision between a bullet, a club and a helmet.i have the shooting in the bag but i need to know how i can do this.when the bullet is shot if it hits the club i want the bullet to be destroyed.if the bullet hits the helmet i need the game to go to the next scene.
-What i want - once the bullet hits a monster OR goes out side of the range of the gun it disappears and another shot can be fired (which is done automatically via my script no user input needed)
-What i have - when the bullet goes off the page (x>550, x<0, Y>400, Y<0) it disappears and another shot can be fired... obviously this is problematic to game play...
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); }
It seems any type of linebreak within an <LI> tag create an extra bullet?The following examples all produce 2 bullets when they should only show one...