Page 1 of 1

question about animation

PostPosted: Tue Jan 25, 2011 2:45 am
by hamdotkeren
1.what is the code for animation finish in script editor?? (without using animation finish event)

2.I want to create a character, if I press a button repeatedly (eg, the "h") then the character will change into another animation and perform such an attack combo, and if I release a set of repetitive button presses (when the middle combo or end) then the animation will automatically return at the beginning. like a combo hit fighting game in general.
how to apply it in GE?
or if there is such a demo that I mean, could you please show me the link??

Re: question about animation

PostPosted: Tue Jan 25, 2011 3:13 am
by skydereign
1. Use this.
Code: Select all
if(animpos==nframes-1)
{
    // animation finish code
}


nframes holds the total number of frames in an animation, and animpos is the frame index ranging from 0 to nframes-1.

2. You could use the idea from the above code, and use a variable to hold your actor's place in the combo. I would just use a state variable, like this.
player -> KeyDown (h) -> Script Editor
Code: Select all
switch(state)
{
    case 0: // standing
    // ChangeAnimation to attack
    state=2;
    break;

    case 1: // start combo
    if(animpos>=nframes-2) // not quite the last frame
    {
        // ChangeAnimation to second combo
        state=4;
    }
    break;

    case 4: // second hit in combo
    if(animpos>=nframes-2) // same as above
    {
        // ChangeAnimation to next combo hit (or repeat part of the combo)
        state=4; // this would be used if you are repeating the second hit
    }
    break;

    // and so on
}


Of course you would do this for both directions the player is facing, and have other states that you could enter the combo from, like running perhaps. If you need the state method explained, just ask, but generally speaking this is how you might do it.

Re: question about animation

PostPosted: Tue Jan 25, 2011 9:05 am
by hamdotkeren
this is my demo
there I'm still using animation finish event, I want to without the use of animation finish, but by using scrip editor, can you fix it me!!

Re: question about animation

PostPosted: Tue Jan 25, 2011 11:06 pm
by schnellboot
why not do yourself?

Re: question about animation

PostPosted: Wed Jan 26, 2011 12:14 am
by sonicfire
@ hamdotkeren :

Code: Select all
if(animpos==nframes-1)
{
    // animation finish code
}


..this *is* the same as animation finish! :)

Re: question about animation

PostPosted: Wed Jan 26, 2011 7:42 pm
by hamdotkeren
hehehe, I've done it time ago but the code does not work, but somehow now, may I now have received a revelation ... hehehe, thanks to much bro

you are smart peoples...