PDA

View Full Version : Timed event



kingofnukes
July 4th, 2005, 03:40 PM
I need help with a plasma gun i made. When it shoots, the heat gage goes up. I want it to go to the frame on the Mc where the heat drops when you dont shoot for 3 seconds. (kinda like the halo plasma guns)

kingofnukes
July 4th, 2005, 04:01 PM
you can use this to see what i mean. (notesome of the frames of the steam have been removed so it looks crappy and may confuse you.)

Blackspirit
July 5th, 2005, 04:06 AM
well, you'll need a frame counter for that and some onEnterframe stuff.

we'll put on onClipEvent(enterframe) handler on your gun. This triggers everytime a frame goes by.
If the enterframe, we'll put a counter, say "heatPenaltyCounter". When the gun is overHeating, we'll add one to this counter and turn off the guns ability to fire.
When it reaches say, 15 ( 1 second if your movie is 15fps ) we'll reset the heatPenaltyCounter and make the gun available to be fired.
If you want to work out if the guns available to be fired, you'll need another variable say "overHeating". When the gun is overheating we trigger it to "true", and when yjr heatPenaltyCounter is 15, we turn it back to "false"

Anyway, I changed some of your file around. Most of the code is on the gun movieclip. Any code you don't know whats going on, just give a shout :D

kingofnukes
July 5th, 2005, 07:17 PM
That's the code I was looking for, thank you. I was just wondering what part of the script to change to make it "cool down" faster. It will help me a lot.

Blackspirit
July 5th, 2005, 11:13 PM
on the gun movieclips onload:

//how many frames before one heat dissapates
var heatCoolDown = 15;

heatCoolDown is how many frames it takes to take one heat away. So the more frames, the longer it takes. If you change that to 5, it'll cooldown pretty quick.

kingofnukes
July 5th, 2005, 11:19 PM
Thank you. Now i can work on my other wepons.