Image not moving

Hi,

I tried to include motion effect for three images in a row (768*1296). Second and third image is moving from left to right and vice a versa. However the animation for first starts very slowly after the third animation is done.

Am I doing something wrong?


void WelcomeTemplateApp::setup()
{

	mWindow1 = gl::Texture::create(loadImage(loadAsset("1.jpg")));
	mWindow2 = gl::Texture::create(loadImage(loadAsset("2.jpg")));
	mWindow3 = gl::Texture::create(loadImage(loadAsset("3.jpg")));

	mWindow1Anim = vec2(-200.0, 0.0);
	mWindow2Anim = vec2(0.0, getWindowHeight() / 3);
	mWindow3Anim = vec2(-20.0, 2.0*getWindowHeight() / 3);

	

}

void WelcomeTemplateApp::update()
{
	const float kDuration = 5.0f;

		timeline().apply(&mWindow1Anim, vec2(50.0, 0.0), kDuration, EaseInOutQuad());
		timeline().appendTo(&mWindow2Anim, vec2(-20.0, getWindowHeight() / 3), kDuration, EaseInOutQuad());
		timeline().appendTo(&mWindow3Anim, vec2(0, 2.0*getWindowHeight() / 3), kDuration, EaseInOutQuad());
}


Regards
Rachana

Hi,

the update() method is called 60 times a second (once per frame), so you are rescheduling your animations over and over again. Try moving the timeline().apply() and timeline().appendTo() calls to your setup() function, or to a mouseDown() method.

-Paul

Hi Paul,

You are amazing. Thanks, I am able to see the effects running fine now.

But I am slightly confused. What if I want to have slides of presentation and then take entire thing in loop. Can I perform loop function in setup() itself? Or will I have to write in mousedown()?

Regards
Rachana