all groups > flash actionscript > july 2006 >
You're in the

flash actionscript

group:

Shooting


Shooting DarkVortex
7/7/2006 9:57:16 PM
flash actionscript:
im making a space invaders type game and i need help with the shooting.im using
the mouse to move and im making the spacebar to shoot but what kkeps happening
is if you press space it shoots. but if you press it again before the tween
ends it shoots again. i was going to do variables but i dont know how. here is
my code so far:

onClipEvent (load) {
_x = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
_x += (endX-_x)/speed;
}
on (keyPress"<space>") {
gotoAndPlay(2);
}

Re: Shooting DarkVortex
7/8/2006 1:17:33 PM
Re: Shooting FlashAmit
7/8/2006 1:46:44 PM
it appear you are using the space craft with bllet animation i.e. the bullet
animation is in the craft movie clip.
Make the space craft and bullet animation separate.
set identifier "bullet" to the bullet animation. Then
declare a root var

var counter;
on (keyPress"<space>") {
this.attachMovie("bullet", "b"+counter, this.getNextHighestDepts())
eval("b"+counter).gotoAndPlay(2);
counter++;
}
on the last frame of bullet movieclip

this.removeMovieClip();


Re: Shooting DarkVortex
7/8/2006 3:19:03 PM
Re: Shooting DarkVortex
7/8/2006 10:10:42 PM
oops, i tried your code and it works but i have one problem. how do i gt the
bullets to go in a strait line. if i move while a bullet is going then the
bullet moves too. whats wrong. here is the code. i modified it a little.

onClipEvent (load) {
_x = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
_x += (endX-_x)/speed;
}
on (keyPress "<Space>") {
this.attachMovie("Bullet", "b", this._x);
}

Re: Shooting DarkVortex
7/8/2006 11:28:12 PM
Re: Shooting DarkVortex
7/8/2006 11:49:46 PM
Re: Shooting FlashAmit
7/15/2006 12:00:00 AM
on (keyPress "<Space>") {
this.attachMovie("Bullet", "b", this._x);
}
it attaches the code to space craft.

make a button outside the screen name it say 'fire'.

on the frame write
var counter = 0;
fire.keyPress = fuunction(){
if(Key.SPACE){
counter++;
_root..attachMovie("Bullet", "b"+counter,counter);
_root.eval("b"+counter)._x = _root.spaceCraft._x;
_root.eval("b"+counter)._y = _root.spaceCraft._y;
}
}
Re: Shooting DarkVortex
7/21/2006 8:53:20 PM
AddThis Social Bookmark Button