So, right, I can do all keypress stuff. But here's a problem I've got. Might be a bit long, but I hope you could help.
Here's the link:
http://i52.photobuck..4/King_Scar/dmc3.swf
Controls:
A - left
D - right
S - duck
K - Jump
L - Attack
So I've got one onClipEvent, and underneath that is all the basic actions. (move, duck, attack). On another, is jump.
//========================================
=========
// MOVEMENT
//========================================
=========
onClipEvent (enterFrame){
this._y += gravity
//MOVE RIGHT
if (Key.isDown(68)){
this._x += movespeed
this._xscale = 150
if (_root.isFloat == "TRUE"){
this.gotoAndStop(4)}
else{
this.gotoAndStop(2)}
}
//MOVE LEFT
else if (Key.isDown(65)){
this._x -= movespeed
this._xscale = -150
if (_root.isFloat == "TRUE"){
this.gotoAndStop(4)}
else{
this.gotoAndStop(2)}
}
//SIT
else if (Key.isDown(83)){
if (_root.isFloat == "FALSE"){
this.gotoAndStop(5)
_root.isSit = "TRUE"}
}
//ATTACK
else if (Key.isDown(76)){
if (_root.isFloat == "FALSE"){
if (_root.isSit == "TRUE"){
this.gotoAndStop(8)}
else if (_root.isSit == "FALSE"){
this.gotoAndStop(6)}}
else if (_root.isFloat == "TRUE"){
this.gotoAndStop(7)}
}
else if (Key.isDown(Key.SPACE)){
this.gotoAndStop(10)}
else{
if (_root.isFloat == "TRUE"){
this.gotoAndStop(4)}
else{
this.gotoAndStop(1)}
gravity = 10
_root.isSit = "FALSE"}
}
//JUMPING
onClipEvent (enterFrame){
if (Key.isDown(75)){
this._y -= jumpspeed
this.gotoAndStop(3)
_root.isSit = "FALSE"
gravity = 0
jumpspeed = (jumpspeed - antijumpspeed)
if (jumpspeed <= -10){
jumpspeed = -10
this.gotoAndStop(4)}
}
else{
gravity = 10
}
}
The problem is this: I need to have Dante (that guy) do different attacks by different key combinations (like DMC3). For example, press D + K (in other words, RIGHT + ATK) should make Dante do a Stinger move, which is a forward lunge attack.
But there's a conflict. If I put the special moves on the same onClipEvent, the Stinger animation won't play. Infact, he just remains standing. It's prolly because it's conflicting between either to play the Run animation or the Attack animation.
CODE:
else if (Key.isDown(76)){
if (_root.isFloat == "FALSE"){ checks if he's on land
if (_root.isSit == "TRUE"){ checks if he's sitting
this.gotoAndStop(8)}
else if (_root.isSit == "FALSE"){
if (Key.isDown(68)){ check if "D" key is also pressed down.
this.gotoAndStop(15)
if (this.mcDanteStinger._currentframe >= 7 && this._xscale == 150){ if the Stinger animation's _currentframe is > 7, Dante will start moving forward
this._x += 10
_root.isStinger = "TRUE"}
else if (this.mcDanteStinger._currentframe >= 7 && this._xscale == -150)
this._x -= 10
_root.isStinger = "TRUE"}}}
// set isStinger to FALSE on enemy collision
else if (_root.isFloat == "TRUE"){ if Dante's on air, just execute simple aerial attack
this.gotoAndStop(7)}
I wish NG allowed tab spacing so everything gets clearer.
I can't put if ((Key.isDown(76) && (Key.isDown(68))) on the topmost condition, because Dante will execute Stinger on air.
So I tried putting it in another onClipEvent. And there's still conflict. It plays, but it just stops on the first frame of the basic Attack animation. Furthermore, it just stacks up the Stinger ._x+ with the runspeed. >.<
I really hope you understood. Could you help me? The words "keylistener" might help me, but I still don't know how to really use it and AFAIK, it just detects when keys are pressed/released, which sound like Key.isDown to me.
If you notice, Dante's feet goes through the floor sometimes when he lands. Another bug I can't figure out. :'(