At 6/12/09 03:16 AM, damianemtum wrote:
hi,
im making a plataformer game i already have movement , stages, health, etc etc
but im having problems with the "combos"
i want that my char when i press (for example "spacebar" ) hit and when i press spacebar again it makes another different hit and so
i know that i have to draw different frames inside the movieclip for each hit
but i dont know how to make it works :S
any help?
As with most things, there'll be many ways to do this. I'll suggest one possible way but bear in mind that
1) I technically use AS1
2) I openly admit I'm not a programmer - just someone who's been (just barely) willing to do so in the past in order to realise a few of my simpler ideas.
By the way, I'll leave the syntax up to you, rarely going further than pseudocode.
Have a boolean flag called something like 'punching'.
When space is pressed, if (!punching) {gotoAndPlay(the first frame of the punching animation; punching=true; combo=true;}
Without the boolean check, you'd be able to punch as fast as the key is hit.
In the animation, I'd personally have x punches, each lasting n frames with the fist/foot making 'contact' and pausing for the last m frames. x is the maximum combo you want folk to be able to do and m is the timeframe of opportunity for hitting the combo. n should be defined by how quickly you want the character to be able to strike, how quickly you want players to need to press the button... consider both aesthetics and gameplay. Experiment and maybe research some classic console games with the aid of a stopwatch.
I'd personally keep n and m constant, since I like simplicity - specially in flash games - but testing may reveal that it's better to speed it up as the combo goes on or vary the tempo. And of course it's a design issue I'll largely leave up to you.
Anyway, on each little punch animation, you've got the last m frames where if a user clicks, they should hit again. Have damage be dealt on the n-mth frame (e.g. if n is 25 and m is 7, deal damage on the 18th frame) Over the last m frames, have code:
if they hit the button, if (combo) gotoAndPlay the first frame of the next hit animation.
On every other frame, if they hit the button {combo=false;}
This will stop folk just hammering the button as quickly as they can - a pet peeve of mine. Remember to signal everything visually to players - including a 'broken combo' - maybe even have code to pop up a big message on the stage here if combos are a big focus.
Then on the nth frame, gotoAndPlay the non-fighting animation. The only way the nth frame is reached would be by the button not having been hit by then. (or the button having been hit prematurely)
Of course, you have to decide - should the character be able to move during combos? Should there be a combo tree? The tree could be easily done as an expansion of the system I outline above. Moving during combos, I leave up to you. It could be perhaps done by having left/right not move the character directly during a combo but rather set a flag to say which direction the next hit will be in. Then use a tree system. Or maybe have two attack buttons - one for each side.
Of course, if you don't need variation between punches (either in timing or graphically), the entire thing could be done with n frames, no need to have the repeats, but I'd strongly recommend it - if only to give some graphical 'reward' to those that access the combo, as well as signalling that they've done so.
As I always say, you can get far with just the basic variables, gotoAndPlay and some thinking. Remember - Pico's School was originally made in Flash 3!
Hope that was intelligible! :-)