Gun shooting

I have go a gun that looks like it shoots but no bullets come out of the gun. I dont know how to do this and I am sort of new to flash. Could you please fill in any missing code and anything else you want on the attached file. Any help on this would be gr8. cheers

Man you are really a beginner! If i were to help you i would be better of making something from scratch than using your example!But i am currently busy with my exams, so i am just gonna give some tips now

1)your bullet depletion code is the silliest i have seen so far…onClipEvent(enterFrame){} executes all the code in the braces every game loop…that is everytime the playhead reads that frame. So if you have multiple statements put them in one enterFrame function only:


onClipEvent(enterFrame)
{
 if(condition1)
   statement
 else if(condition2)
   statement
...
...
}

but a game designer isn’t a spriter, he should be more of a programmer, and as a programmer you should find the shortest and most flexible route available to you. For example, the above scenario can be minimised as:



onClipEvent(enterFrame)
{
 for(i=50;i>0;i--) //i starts at 50, and as long as it is greater than 50, lower it by 1
  {
   if(ammo==i)
     _root.bullets.gotoAndStop(50-i) //so if, say you have 45 ammo, it will stop at 50-45=5th frame!!
  }
}

2)Your main problem is however, that you cant use attachMovie() properly! Your bullet depletion should have been done with attachMovie, and removeMovieClip() and not with a 50 frame animation, since code gives you greater flexibility than animation! Anyway, the same attachMovie is again required to actually fire a bullet, but rather than stating it here, search google for examples on it…you will learn faster!

if you have problems understanding something, feel free to ask me!

thanks for the help. I did say that i was new to flash :slight_smile: Could you make me a quick gun that turns and add a bullet so I can understand it better plz (I will start from scratch dont worry)

As i said earlier, i am a bit busy now with my exam, so i cant really help you, but heres a very nice example that, if you can understand, will teach you a lot of things:

http://www.emanueleferonato.com/2008/03/27/create-a-flash-game-like-bloons-tutorial/

thank you very much you have been a good help and good luck with ur exams :slight_smile: