PDA

View Full Version : launch projectile



frookan
March 11th, 2004, 08:53 PM
well im working on a pretty easy game, im gunna have it so you are on the bottom using the left and right arrow keys, and when you press space bar it shoots somthing up...i used this code on the projectile:if (key.isDown(key.SPACE)) {
this._y -= 8;
this._y = 350;
this._x = _root.guy._x;
}
but it wont launch, also i want it so you can only launch three at a time..how would i do that?....(i attached the file)

Hi_Nu
March 11th, 2004, 09:32 PM
Originally posted by frookan
well im working on a pretty easy game, im gunna have it so you are on the bottom using the left and right arrow keys, and when you press space bar it shoots somthing up...i used this code on the projectile:if (key.isDown(key.SPACE)) {
this._y -= 8;
this._y = 350;
this._x = _root.guy._x;
}
but it wont launch, also i want it so you can only launch three at a time..how would i do that?....(i attached the file)
Ok, your code this._y = 350 is over riding your this._y -=8 what you sould do is somthing like this (made quickly)function bullet (){
// 32 is the key code for space bar, note, code may be not right because I did this on the comp, but gives geral idea,
if(key.isDown(32){
wepon = dublicateMovie(this,this+i);
}wepon._y -= 8
wepon._x = _root.guy._x;
}

frookan
March 11th, 2004, 09:50 PM
no, it didnt seem to work, i may have done it wrong but i dont think i did....

Amax2
March 15th, 2004, 11:02 PM
hopefully this will help with your projectile problems

frookan
March 16th, 2004, 04:00 PM
Originally posted by Amax2
hopefully this will help with your projectile problems
wow thats...alot more then i need...in the game i want, im going to have a player be able to move on the bottom of the screen (only right and left) and when they click space bar an image launches up...i know all the coding for the movements and all i just dont know how to have it launch