Problem
- KuchiyoseRashomon
-
KuchiyoseRashomon
- Member since: May. 7, 2007
- Offline.
-
- Forum Stats
- Member
- Level 26
- Animator
Okay I finally got one problem fix but opens another. Well anyways i fixed one problem where for some odd reason when you press 2 keys didn't play a certain animation, the code does respond now but the animation doesn't play (How I know is because it starts the animation but doesn't continue), the idea is that when my character is running and when the A key is pressed it plays the character running but also shooting, however I cant seem to get it to do the animation, I tried adding booleans but it didn't work either, any suggestions, below is the code (well the main part that, you notice its rather strangely built because my last problem was it wouldn't respond to two keys been pressed if I place the code where It commands the two keys to be pressed, it works). So basically can anyone help fix me this, so I can get my player to run while shooting
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT) && Key.isDown(65)) {
_root.bulletpos = _root.player._x+24;
_root.facing = "right";
this._xscale = 100;
this.gotoAndStop("runningShooting");
runningandshooting = true;
} else if (Key.isDown(Key.LEFT) && Key.isDown(65)) {
_root.bulletpos = _root.player._x-24;
_root.facing = "left";
this._xscale = -100;
this.gotoAndStop("runningShooting");
runningandshooting = true;
}
}
onClipEvent (load) {
hitwallr = false;
hitwalll = false;
grav = -1;
jumping = true;
running = false;
i = 0;
runningandshooting = false;
}
onClipEvent (load) {//allows me to shoot, second half code is within the bullet
_root.facing = "right";
_root.bulletpos = _root.player._x+24;
moveSpeed = 15;//movement of bulletoooz
_root.gun._visible = false;//bullet not visible, you cant see it
guns = 1;//original number of guns
maxguns = 3;// my dear good sir, this only allows how much a bullets can enter the screen
depthcount = 3;//original depth
}
onClipEvent (enterFrame) {
if (Key.isDown(65) and (guns<=maxguns)) {//if you hit control and the number of bullets on stage is less than or equal to maxguns
guns++;//Add 1 to guns bullets on stage
_root.gun.duplicateMovieClip("gun"+depth count,depthcount);// Duplicate the gun movie clip calling it "gun" and the depthcount, and giving it a new depth
_root["gun"+depthcount]._visible = true;// show the duplicated movie clip "gun"
depthcount++;//add 1 to the depthcount
runningandshooting = false
if (depthcount>maxguns) {//if depthcount is greater than maxguns
depthcount = 1;//reset to 1
runningandshooting = false
}
}
if (Key.isDown(Key.LEFT)) {//movement with shootinh binary
_root.bulletpos = _root.player._x-24;
_root.facing = "left";
this._x -= 5;
this._xscale = -100;
this.gotoAndStop("running");
_parent._x += 5;
_root.vcam._x -= 5;
runningandshooting = false;
} else if (Key.isDown(Key.RIGHT)) {
_root.bulletpos = _root.player._x+24;
_root.facing = "right";
this._x += 5;
this._xscale = 100;
this.gotoAndStop("running");
_parent._x -= 5;
_root.vcam._x += 5;
runningandshooting = false;
} else if (Key.isDown(65)) {
this.gotoAndStop("shooting");
runningandshooting = false;
} else {
this.gotoAndStop("idle");
}
}
- KuchiyoseRashomon
-
KuchiyoseRashomon
- Member since: May. 7, 2007
- Offline.
-
- Forum Stats
- Member
- Level 26
- Animator
- kylelyk
-
kylelyk
- Member since: May. 15, 2008
- Offline.
-
- Forum Stats
- Member
- Level 10
- Blank Slate
- MichaelJ
-
MichaelJ
- Member since: Mar. 2, 2009
- Offline.
-
- Forum Stats
- Member
- Level 18
- Voice Actor
- onezerothrice
-
onezerothrice
- Member since: Jul. 16, 2009
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
This is one of the inherent problems with AS2 keyboard events that was made better in AS3, in that you can read when any key is pressed down or released, at any time, with one function, with the KeyboardEvent class. If you're working in CS3 or later, I suggest moving the project to AS3.



