PDA

View Full Version : Stupid Enemy!


Insane Knux
01-16-2007, 05:41 PM
Okay, I have my enemy; he shoots... But, he shoots so much he lags the game! How would I make a timer for his shooting?
Or like,
To where he has to be near you to shoot?
Here's the current game. http://img68.imageshack.us/my.php?image=shot2wd4.swf

Any help?

phdrummer
01-16-2007, 05:43 PM
let me check my flash, i cant find it now but it is like timer++ then in the fram you do like Call timer

Mr. Anderson
01-16-2007, 05:58 PM
Damn man, that crap almost shut down FF.

Get a tut. >.>

Jacob
01-16-2007, 06:06 PM
Use setInterval(), its the best way. The way phpdrummer is talking about is basic and can be used. Something like:

timer++
if(timer%30 == 0){
//fire
}A person who knows how to use setInterval() doesnt do it that way though, so my suggestion is to learn it.

Matt
01-16-2007, 06:10 PM
I'd simply make a timer or make it play an animation of like reloading after each shot.

ry79418
01-16-2007, 06:10 PM
Set interval, heres a tutorial

http://www.webwasp.co.uk/tutorials/b56-setInterval/index.php

clan_carrot
01-16-2007, 06:12 PM
i don't think its thats going to work :(

Malignus
01-16-2007, 06:14 PM
*quotes Boris from Golden Eye* I am eeen-veeen-cee-bul!

When he shoots me, all I do is turn invisible and invulnerable--I can still run around, fire shots, and kill him. :D

Insane Knux
01-16-2007, 07:06 PM
lol I know - I'll fix that later.
Okay problems: This doesn't work.

i = 0;
f = 0;
spd = 10;
onLoad = function(){
duplicateMovieClip("ene1", "ene", this.getNextHighestDepth);
_root.ene._x = 200;
_root.ene._y = 200;
}
onMouseDown = function(){
i++
duplicateMovieClip("bull", "bull"+i, i);
_root["bull"+i]._x = _root.you._x;
_root["bull"+i]._y = _root.you._y;
_root["bull"+i]._rotation = _root.you._rotation;
}
you.onEnterFrame = function() {
f++
duplicateMovieClip("eba", "eba"+f, f);
_root["eba"+f]._x = _root.ene._x;
_root["eba"+f]._y = _root.ene._y;
_root["eba"+f]._rotation = _root.ene._rotation;
myTimer = setInterval(wait, 2000);
function wait() { // a function called 'wait'
clearInterval(myTimer); //stops the function being called again.
}
the timer doesn't help...

Mr. Anderson
01-16-2007, 07:42 PM
I don't know about that fancy code, but if it isn't, use an interval (call the guys weapon a Shotgun >.>)

phdrummer
01-16-2007, 07:53 PM
Use setInterval(), its the best way. The way phpdrummer is talking about is basic and can be used. Something like:

timer++
if(timer%30 == 0){
//fire
}A person who knows how to use setInterval() doesnt do it that way though, so my suggestion is to learn it.
for the 50th time its phdrummer not php drummer, i dont know php! My name is phil, henche PH and drummer, well yeah.

phdrummer
01-16-2007, 07:55 PM
i don't think its thats going to work :(Just leave. LEAVe

Ok on the weapon play just make it a couple frames longer so he can't shoot that often.that makes no difference, you dont know how AS works do you, it Duplicates the Movie Clip Bullet it doesn't play an animation

Jacob
01-16-2007, 07:58 PM
You are using it wrong. Toss the onEnterFrame too. You need to use setInterval to call the function that makes the enemy shoot, not a function that just stops the interval. That code is like saying "wait 2 seconds, then dont do anything and dont wait 2 seconds to do nothing again"


var myTimer = setInterval(EnemyShoot, 2000);

function EnemyShoot()
{
trace("shoot");
}Change the you.onEnterFrame function to a non enterframe function, like EnemyShoot shown above. Use clearInterval when you want the loop to stop. Imagine it as a really slow onEnterFrame event that you can have repeat as slow or fast as you want.

Understand?

Insane Knux
01-16-2007, 08:32 PM
That makes perfect sense! Thanks! I'll try it.

phdrummer
01-16-2007, 08:35 PM
reading stuff likethis helps my logic, and ASpting

doomlord
01-19-2007, 04:14 AM
also make the wall push you back because i thought it would so i walked into it then the enemies gunshots killed me heh but yeah have an interval timer for it or have a random timer for like 2-3 seconds