2
votes

I am programing a little game in flash,

and I am programing the animations of the character,

the character body is made of different objects, for example, I have an movie clip that is the head, Torso, Arms, Hands, Legs, etc,.

and I am making the animations with AS3, for example:

(only programed 1 leg movement)

public function walk(){
        if(_etapa==5){
            _etapa=1;
        }
        var etapa=_etapa;

        switch(etapa){

            case 1:
                Animar(musloDer,22,RetomarAnimacion);

            break;

            case 2:

                Animar(musloDer,0,RetomarAnimacion);
            break;

            case 3:
                Animar(musloDer,-22,RetomarAnimacion);
            break;

            case 4:
                Animar(musloDer,0,RetomarAnimacion);
            break;

        }




    }

the walk animation haves 4 stages,

then I have the Animar function:

private function Animar(parte, valor, callback){
        trace(direccion);
        if(direccion=="SE" || direccion=="NO"){

            valor=valor+45
            valor=Math.abs(valor);
            if(valor>180){
                valor=360-valor;
            }
            if(valor<0){

            }

            _scaleY = (1-(valor)/90);
            trace(_scaleY);
            _rotation = 0;


        }
        else if(direccion=="N"  || direccion=="S"){



            _scaleY = .5;
            _rotation = -valor;
        }

        _etapa++;
        TweenLite.to(parte, 2.5, {rotation:_rotation, scaleY:_scaleY,ease:Linear.easeNone, onComplete:caminar});

    }

that function moves the body part to the degrees that I want, It also decides what to do, the character can walk in 8 directions, front back, left right, and diagonals, and the character is showed from isometric view,. So the animation function decides what to do depending on the direction that the character is.

for example, if the character is walking right, viewed from lateral view, in that case rotating one leg 22 degrees is very simple, just LeftLeg.rotation = 22; great, but when the character is facing the camera, the leg rotation is not a rotation, is a change in scaleY property, for example, since the body is in isometric view, the scaleY of 1 leg in normal position is .5 (or 50%) when the leg is at 45º the scaleY is 1, and so on.

But I have a problem, because, for example if the LEG initial position is 0º (scaleY = 0.5) and I want to move it to 90º, 90º would be also scaleY = 0.5, so my function does nothing, it tweens from .5 to .5 (nothing), it should go from .5 to 0 and then to .5 again.

I hope someone understands my problem.

best,

Alvaro

1
Well I already fixed it, I ended up making a third function that divides the anim in 10 pices, for example, the main walk animation haves 4 stages, not I am not making just 1 tween for stage, I am dividing the stage in 10, and making 10 tweens for each one of the 4 stages, that fix my problem for large amplitude rotations.Alvaro Hernandorena

1 Answers