Forum Topic: Key combination problem

(71 views • 5 replies)

This topic is 1 page long.

<< < > >>
None

WolfAkela

Reply To Post Reply & Quote

Posted at: 6/5/06 08:37 AM

WolfAkela LIGHT LEVEL 08

Sign-Up: 12/19/05

Posts: 2,136

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. :'(

None

WolfAkela

Reply To Post Reply & Quote

Posted at: 6/5/06 10:54 AM

WolfAkela LIGHT LEVEL 08

Sign-Up: 12/19/05

Posts: 2,136

Uhhh.... anyone?


None

WolfAkela

Reply To Post Reply & Quote

Posted at: 6/6/06 12:50 AM

WolfAkela LIGHT LEVEL 08

Sign-Up: 12/19/05

Posts: 2,136

I guess the long code freaked out everyone. :'(


None

KougaijiGyumao

Reply To Post Reply & Quote

Posted at: 6/6/06 04:28 AM

KougaijiGyumao EVIL LEVEL 08

Sign-Up: 05/26/06

Posts: 157

Oh noes!! Dante fell!! Dude, lucky you, you got the platform to work... I can't seem to make mine work...


None

WolfAkela

Reply To Post Reply & Quote

Posted at: 6/6/06 11:09 AM

WolfAkela LIGHT LEVEL 08

Sign-Up: 12/19/05

Posts: 2,136

You can taunt by holding the Space bar, I forgot. X3

Kougaiji,
It took me days to get that damn jumping engine work. The ones posted at AS:Main didn't work for me, so I had to think it up. :(

Umm... you don't happen to watch Saiyuki Reload, do you?

Anyone who can help me? :(


None

Chrispington

Reply To Post Reply & Quote

Posted at: 6/6/06 09:53 PM

Chrispington EVIL LEVEL 31

Sign-Up: 07/02/04

Posts: 1,247

So, it starts a move but then runs the next bit of code whuch ovverides it?

try this:

if ((Key.isDown(65))&&(!Key.isDown(87))&&(!Ke
y.isDown(83)))

the 'if' will only run if 65 is down, and NOT 87 or 83. This is accomplished but the !, which basically means not.

so do this on all your key presses to your satisfaction. then if you pressed a direction and an attack, you could make the direction IF only run if there were no attack keys pressed. You get the idea?

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 07:52 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!