Hi i'm making flash game and i have some problems. On www.dflame.net/ermac.swf and www.dflame.net/ermac1.fla (source).
When you press arows for move, Z and X for run my "ermac" move but not good. He must w8 about 2 seconds and then he start move's. I dont know why. Thanks for help.
Thanks :) But now when You press AROW or RUN + C or V "ermac" have sliding effect.
That's because honestly I didn't take the time to see what the other buttons did; so when you were walking and pressed the kick button the enterframe function was still moving him.
So for all key strokes where you want him to stop & do an action, i.e. kick, add the delete _root.onEnterFrame. Congress Moves To Seize Control Of All US Water:: Congress Moves To Seize. Control Of All US Water. From Bathtubs To Baptismal Fonts, Congress Moves Wetlands (HR 2421) Bill Gives Corps Control Over Your Property http://www.rense.com/general80/cpn.htmHOME |
Here is the full code:
ermacListener = new Object(); Egypt moves to control border / Riot police struggle to keep :: Article:Egypt moves to control border / Riot police struggle to:/c/a/2008/01/26/MNEQULKK9.DTL That move produced international protests and the Hamas http://www.sfgate.com/cgi-bin/article.cgi?f=/c/a/2008/01/26/MNEQULKK9.DTLHOME | DflDoc / Control-Control-move | Dprogramming.com Wiki - The D :: control. data. drawing. environment. event. filedialog. folderdialog. fontdialog. form. groupbox Describe Control-Control-move here. http://wiki.dprogramming.com/DflDoc/Control-Control-moveHOME |
ermacListener.onKeyDown = function() {
if (Key.getCode() == 39) {
_root.onEnterFrame = function() {
postac._xscale = 100;
postac.gotoAndStop("chod");
postac._x += 5;
};
} else if (Key.getCode() == 37) {
_root.onEnterFrame = function() {
postac._xscale = -100;
postac._x -= 5;
postac.gotoAndStop("chod");
};
} else if (Key.getCode() == 88) {
_root.onEnterFrame = function() {
postac._xscale = +100;
postac._x += 10;
postac.gotoAndStop("bieg");
};
} else if (Key.getCode() == 90) {
_root.onEnterFrame = function() {
postac._xscale = -100;
postac._x -= 10;
postac.gotoAndStop("bieg");
};
} else if (Key.getCode() == 67) {
delete _root.onEnterFrame;
postac.gotoAndStop("LK");
} else if (Key.getCode() == 86) {
delete _root.onEnterFrame;
postac.gotoAndStop("HK");
} else if (Key.getCode() == 39 or Key.getCode() == 37 and Key.getCode() == 67) {
delete _root.onEnterFrame;
postac.gotoAndStop("PolObrot");
}
};
ermacListener.onKeyUp = function() {
delete _root.onEnterFrame;
postac.gotoAndStop("stoi");
};
Key.addListener(ermacListener);
It's because when you press keys such as the right arrow it fires the key once, then delays a second to then keep them repeating.
The get around this add _root.onEnterFrame function to the keys that cause moment; basically in your actions layer on the main timeline replace ALL the code with this:
ermacListener = new Object();
ermacListener.onKeyDown = function() {
if (Key.getCode() == 39) {
_root.onEnterFrame = function() {
postac._xscale = 100;
postac.gotoAndStop("chod");
postac._x += 5;
};
} else if (Key.getCode() == 37) {
_root.onEnterFrame = function() {
postac._xscale = -100;
postac._x -= 5;
postac.gotoAndStop("chod");
};
} else if (Key.getCode() == 88) {
_root.onEnterFrame = function() {
postac._xscale = +100;
postac._x += 10;
postac.gotoAndStop("bieg");
};
} else if (Key.getCode() == 90) {
_root.onEnterFrame = function() {
postac._xscale = -100;
postac._x -= 10;
postac.gotoAndStop("bieg");
};
} else if (Key.getCode() == 67) {
postac.gotoAndStop("LK");
} else if (Key.getCode() == 86) {
postac.gotoAndStop("HK");
} else if (Key.getCode() == 39 or Key.getCode() == 37 and Key.getCode() == 67) {
postac.gotoAndStop("PolObrot");
}
};
ermacListener.onKeyUp = function() {
delete _root.onEnterFrame;
postac.gotoAndStop("stoi");
};
Key.addListener(ermacListener);
What I did was:
Remove the onEnterFrame that was firing the addListener as it only needs to happen once
Added _root.onEnterFrame functions to each if statement looking for keys for moment
Added delete _root.onEnterFrame on key up.
Steve THX you are the best :)
Challenging Books For A 14 Year Old?
First guitar : acoustic or electric?
|