2 Replies Latest reply on Apr 6, 2015 8:57 AM by michael cardeiro

# How do I make two pictures alternate between one another like a video game sprite?

Hello everyone!

I'm currently making a animation of space invaders, however I have encountered an issue. I need to be able to have all the space invaders move, and with each movement change shape. My original plan was to use two models and change their opacity every 15 frames from 0 to 100 so one would be at 100 opacity while the other would be at 0. I can't figure out how to do this other than to go through it frame by frame, changing the movement and opacity, and I have to believe there is any easier way to do this. I need the opacity to change from 0 to 100 with no transition (So 0-100 not 0-20-40-60-80-100).

Any help is appreciated!

• ###### 1. Re: How do I make two pictures alternate between one another like a video game sprite?

Use hold keyframes. Also, you can use a loopOut expression to make them do that movement constantly.

• ###### 2. Re: How do I make two pictures alternate between one another like a video game sprite?

you can do this with expressions.  For fun I played around with a test animation

to do this you would have 2 precomps for each row of aliens depicting the two (one comp has the first alien look, the second comp has the second look all in the same position as the first)

the two comps are placed in a master comp, positioned vertically to where you want them.

this expresion would go in the position parameter of both comps.  it starts horizontal positioning at 0 and increments 100 every 15 frames

/////////////////////// position

var increment = 100;

var t = timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false);

var s = parseInt(t/15);

var pos = transform.position;

[s*increment,pos[1]]

//////////////end position

the next expression would go in the opacity parameter of both comps, it alternates giving 100% opacity between the two comps every 15 frames.  The comps need to appear 1 after the other in the layer stack for it to work.

/////////////////////opacity

var t = timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false) % 30;

var s = (t%30);

var i         = this.index %2;

var change = [0,100];

if(i){

change = [100,0];

}

if(s<15){

o = change[0];

}else{

o = change[1];

}

o;

//////////end opacity

Like I said, I just threw it together to show how expresions could solve it.  Ideally you would need some code in the posion to shift down and reset horizontal position to 0 every so often