They won't fire...[MX]

Neither the player nor enemy will fire at eachother! (That sounds funny, doesn’t it?)
“YOU”(player)
[AS]
on (keyPress “<Enter>”) {
_root.firey = 1;
_root.i += 1;
duplicateMovieClip(_root.bullet2, “bullet2”, i);
}
[/AS]
“BULLET2”
[AS]
onClipEvent (load) {
this._visible = 0;
if (_root.firey == 1) {
this._x = _root.you._x;
this._y = _root.you._y;
}
}
onClipEvent (enterFrame) {
if (this != _level0.bullet2) {
if (_root.firey == 1) {
this._x += 5;
this._visible = 1;
}
if (this._x>0) {
this.removeMovieClip();
}
}
}
[/AS]
“E”(Enemy)
[AS]
rand = random(2);
if (rand == 1) {
_root.fire = 1;
_root.i += 1;
duplicateMovieClip(_root.bullet, “bullet”+i, i);
}
[/AS]
“BULLET”
[AS]
onClipEvent (load) {
this._visible = 0;
if (_root.fire == 1) {
this._x = _root.e._x;
this._y = _root.e._y;
}
}
onClipEvent (enterFrame) {
if (this != _level0.bullet) {
if (_root.fire == 1) {
this._x -= 5;
this._visible = 1;
}
if (this._x<0) {
this.removeMovieClip();
}
}
}
[/AS]
If you can help, that’d be great :smiley:

Well… First off, by the looks of it you can shoot as fast as your Enter Key Hitting finger can hit the key… And this is generally unexceptable due to keyboards and their nature… And the fact that you have a variable that isn’t doing anything right now _root.firey doesn’t help out matters much either…

[AS]
on (keyPress “<Enter>”)
{
if(_root.numMissles < 10)
{
_root.numMissles++;
if(_root.id < 1000){_root.id ++;}else{_root.id=0;}
_root.bullet2.duplicateMovieClip(“bullet2”+_root.id, _root.id);
}
}
[/AS]

There wer two major problems in this statement…

[AS]
duplicateMovieClip(_root.bullet2, “bullet2”, i);
[/AS]

The first mistake was the “bullet2”. That means that a movie was trying to duplicate itself in its own name. Not good. The second thing to note is the single i. If anything it should be _root.i since that variable resides on the _root side and not the actual “you” side…

Now… The next statement…

[AS]
onClipEvent (load)
{
this._visible = FALSE;
if (this.name != “bullet2”)
{
this._x = _root.you._x;
this._y = _root.you._y;
}
}

onClipEvent (enterFrame)
{
if (this.name != “bullet2”)
{
this._x += 5;
this._visible = TRUE;
if (this._x > 0)
{
this.removeMovieClip();
_root.numMissles–;
}
}
}
[/AS]

Now… here are the couple of changes that I made to these couple of lines of code…

[AS]
onClipEvent (load) {
this._visible = 0;
if (_root.firey == 1) {
this._x = _root.you._x;
this._y = _root.you._y;
}
}
onClipEvent (enterFrame) {
if (this != _level0.bullet2) {
if (_root.firey == 1) {
this._x += 5;
this._visible = 1;
}
if (this._x > 500) {
this.removeMovieClip();
}
}
}
[/AS]

Now… No need for the firing method. If the bullet clip is on the screen we only want it to do one of three things… Move, Check to see if it hit something, or check to see if it went offscreen. We just need to make sure the clip we are duplicating doesn’t move… Which was named bullet2. So we do a check to make sure bullet2 isn’t going to move. I changed the 0’s and 1’s to FALSE and TRUE… No biggie really… Just so **** used to doing it that way lmao Other than that… It’s good.

BTW… Change the this._x > ### to whatever width your movie is. :slight_smile:

Next statement.

[AS]
onClipEvent(enterFrame)
{
temp = Math.floor(Math.random()*2);
if (temp == 1)
{
if(_root.eid < 1000){_root.eid ++;}else{_root.eid = 0;}
_root.bullet.duplicateMovieClip(“bullet”+_root.eid, _root.eid);
}
}
[/AS]

Just made a couple of quick changes to this one like I did the statement above. and now the last statement.

[AS]
onClipEvent (load)
{
this._visible = FALSE;
if (this.name != “bullet”)
{
this._x = _root.e._x;
this._y = _root.e._y;
}
}

onClipEvent (enterFrame)
{
if (this.name != “bullet”)
{
this._x -= 5;
this._visible = TRUE;
if (this._x < 0)
{
this.removeMovieClip();
}
}
}
[/AS]

And there you go… Tell me if you are having more problems by e-mailing me. Found in my profile :slight_smile:

yay! Thank you! :smiley:

No problem mate :beer: