View Full Version : bullet holes / sparks
Shadowwave
10-14-2006, 09:35 PM
I have created a gun and i would like it to create bullet holes underneath where it shoots (the mouse) that are created randomly around the crosshair (so the shots arent perfectly in the center, which would make it too easy xD). When the gun is set on burst mode it has to create 3 random bullet holes around the area of the crosshair. How could i do this?
Shadowwave
10-15-2006, 10:02 AM
nvm, i did it with a _root.bullet.duplicateMovieClip("bulletNew", i); command and it works fine, but now im trying to figure out how i can have it so it can be like this:
_root.bullet.duplicateMovieClip("bulletNew", i);
~wait 2 seconds~
_root.bullet.duplicateMovieClip("bulletNew", i);
~wait 2 seconds~
_root.bullet.duplicateMovieClip("bulletNew", i);
Is there any command i can use to make it wait?
sunder
10-15-2006, 10:13 AM
There used to be a delay type command but it might be deprecated or not recommended for use.
A way to approach this is part of a clip loop. Every time you enter a new frame, you use a variable to check if 2 seconds worth of frames have passed. If it has, then you run the code to add the next bullet hole. If not, go on to the next frame.
If you need more info, just ask :)
Shadowwave
10-15-2006, 03:24 PM
more info please :)
my code isnt complex so the delay command should be ok, can you tell me what the code is?
TwinsenDude
10-15-2006, 05:40 PM
So basically when you shoot you have it not only duplicate the movieclip,but also set this, so like this:
in the root you have to have
prevTime = 0;
onClipEvent(enterFrame) {
if (_root.prevTime != 60) {
_root.prevTime ++;
} else {
_root.bullet.duplicateMovieClip("bulletNew", i);
_root.prevTime = 0;
}
}
So what this will do is at first set the variable we created prevTime to 0, and then every time the movieclip enters the frame, it will add to prevTime, so it's adding 1 each frame, so if you're at 30 frames per second and you want to wait 2 seconds, you have to wait 60 frames, so when prevTime gets to 60 we have it shoot and revert prevTime back to 0 to start over again.
also the 60 I put in there is if you're at 30 fps, you need to hcange it to twice whatever your fps is.