Okay I'm pretty much at the end of my rope here, so I need some help. I've searched through over 6000 threads for the Flash MX board here on the site and finally gave up. So anyhow...
In the movieclip called Flik, instance name "wf":
Code:
onClipEvent (load) {
//bullet fire
_root.bullet._visible = false;
bulletCounter = 1;
//initial Flik mc
moveSpeed = 5;
this.attachMovie("walk_down", "wd", 1);
clipToDelete = "wd";
}
onClipEvent (enterFrame) {
//for Flik to walk
if (Key.isDown(97)) {
dPad = 1;
//walk down left
if (clipToDelete != "wdl") {
//test if Flik is already walking in this direction
removeMovieClip(clipToDelete);
//If not, remove the current mc
this.attachMovie("walk_downleft", "wdl", 0);
//attach the clip to walk in direction pressed
clipToDelete = "wdl";
//reset the varible clipToDelete for the next test
} else {
this._y += moveSpeed;
}
this._x -= moveSpeed;
wdl.nextFrame();
} else if (Key.isDown(98)) {
dPad = 2;
//walk down
if (clipToDelete != "wd") {
removeMovieClip(clipToDelete);
this.attachMovie("walk_down", "wd", 0);
clipToDelete = "wd";
} else {
this._y += moveSpeed;
}
wd.nextFrame();
} else if (Key.isDown(99)) {
dPad = 3;
... all the way to dPad=9 and then:
//for bullet fire
if (Key.isDown(Key.CONTROL)) {
bulletCounter++;
_root.bullet.duplicateMovieClip("bullet"+bulletCounter, bulletCounter);
_root["bullet"+bulletCounter]._visible = true;
if (bulletCounter>25) {
bulletCounter=1
}
}
note the dPad = 1, 2, and 3 in bold...
And in my movieclip called bulletfire, instance name "bullet":
Ok, so here's what happens... I have eight different movie clips for a walk animation, capable of letting the character walk in eight different directions (1-4 & 6-9 on the Num Pad). What should happen is bullet calls the dPad variable in wf and depending on what number it is, increments the x & y of the bullet so that when you face left, you shoot left, face right, shoot right, etc.
If it isn't clear enough just ask and I'll try to be more clear... sorry if it is I've been trying to settle this problem for almost 7 hours now...
*Edit* I originally wanted to use the clipToDelete variable you see in the wf mc but since I was having problems I changed it. If it is possible to use the string for each direction, let me know because it would be one less variable and a lot less code.
Last edited by ImprisonedPride; 04-27-2006 at 09:10 PM.
Howdy, I recall answering a question similar to yours. Instead of changing the direction of your bullet on the enterframe, you should change it to animation in your bullet. Attached is an example I made to show what I mean. It's also in Flash MX 2004.
Thanks Mirandir, it worked your way. I couldn't get the FLA to open though. Anyhow, a new problem has arisen! Now that it actually works, it doesn't do what I want it to do with the bullets. You can't see it here, but there is a check just after the onClipEvent(enterFrame) that deletes the mc of the duplicated bullet mc if it's off screen. The this._x inside of each duplicated mc creates a problem that allows me to change the bullets direction half way through firing just by changing the direction of the ship! Case in point; if I start off and fire five or six rounds to the left, and as they approach the left stage edge (where they would normally be deleted), I turn and face the right, the bullets stop dead and start moving to the right. I need each duplicated bullet mc to act independently but I believe the problem is coming from how I'm pathing the clip when I tell it to change it's x and y value? Thanks in advance once again.