Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,545 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,243 people online right now. Registration is fast and FREE... Join Now!




Key.Down Glitch

 
Reply to this topicStart new topic

Key.Down Glitch, To BetaWar: Sorry for not replying or anything i have been really busy

cadeownz
post 4 Oct, 2008 - 07:44 PM
Post #1


New D.I.C Head

*
Joined: 11 Jul, 2008
Posts: 31

Hey,

I have a code that if you press right and down it changes a movieclips frame. It works but if i hold down down and right it just stops on first frame but when you release it plays. I want it so when you hold it down it goes to that frame and plays not just stop on first frame. Probley really easy to fix but im stuck and this is VERY important to get it working.. Please.
Here is ALL the code (it might have to do with some other part) :

NOTE: yspeed is not actually _y it is just a term i used for left (_x-). It is just temporary.

slideStopStance and slideStopStanceL are frames inside frame 1 of main movieclip.

CODE

onClipEvent(load){
    power=1;
    friction=0.95;
    xspeed=0;
    yspeed=0;
}
onClipEvent(enterFrame){
    if(Key.isDown(Key.RIGHT)){
        _root.hero.gotoAndStop(2);
        xspeed +=power;
    }
    if(Key.isDown(Key.LEFT)){
        _root.hero.gotoAndStop(3);
        yspeed +=power;
    }
    if(Key.isDown(Key.DOWN) && Key.isDown(Key.LEFT)){
        xspeed = 1;
        yspeed = 0;
        power = 0;
        _root.hero.gotoAndStop(1);
    }
    if(Key.isDown(Key.DOWN) && Key.isDown(Key.RIGHT)){
        xspeed = 0;
        yspeed = 1;
        power = 0;
        _root.hero.gotoAndStop(1);
    }
    if(Key.isDown(Key.LEFT) && Key.isDown(Key.DOWN)){
        xspeed = 1;
        yspeed = 0;
        _root.hero.stopStance.gotoAndPlay("slideStopStanceL");
        _root.hero._x-=.95;
    }
    if(Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN)){
        xspeed = 0;
        yspeed = 1;
        _root.hero.stopStance.gotoAndPlay("slideStopStance");
        _root.hero._x+=.95;
    }
    if(_root.hero.stopStance){
        xspeed = 0;
        yspeed = 0;
        power = 1;
    }
        xspeed *= friction;
        yspeed *= friction;
        _x += xspeed;
        _x -= yspeed;
}
onClipEvent(keyUp){
    _root.hero.gotoAndStop(1);
}


Thanks in advance !

Oh and also if possible i want it so only if your xspeed or yspeed is more than 0 it goes to slideStopStance. Else if it's 0 i want to to got to stopStance. I tried
CODE
if(Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN) && (xspeed>0)){
_root.hero.stopStance.gotoAndPlay("slideStopStance");
}
if(Key.isDown(Key.RIGHT) && Key.isDown(Key.DOWN) && (xspeed==0)){
_root.hero.gotoAndStop(1);
}

But it doesn't work..

Please help will be MUCH appreciated. smile.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 02:08AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month