You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, June 12th 2018, 4:02am

Playing backwards an animation

Hi, I have a sprite image sequence of 5 frames that starts playing and then stops on the last frame, I want to get it playing backwards after that, from frame 5 to frame 0! I tried but noway! *unsure* Could someone please let me know how to do it from klaus animation code:

<action name="do_crop_animation" scope="local" args="framewidth, frameheight, framerate">
<!-- define local variables -->
calc(local.xframes, (caller.imagewidth /framewidth) BOR 0);
calc(local.frames, xframes * ((caller.imageheight / frameheight) BOR 0));
def(local.frame, integer, 0);

<!-- set the first frame -->
calc(caller.crop, '0|0|' + framewidth + '|' + frameheight);

<!-- do the animation -->
setinterval(calc('crop_anim_' + caller.name), calc(1.0 / framerate),
if(caller.loaded,
inc(frame);
if(frame GE frames, set(frame,4);clearinterval(calc('crop_anim_' + caller.name)); );
mod(xpos, frame, xframes);
div(ypos, frame, xframes);
Math.floor(ypos);
mul(xpos, framewidth);
mul(ypos, frameheight);
calc(caller.crop, xpos + '|' + ypos + '|' + framewidth + '|' + frameheight);
trace(scoubidou);
,
<!-- stop the interval when the hotspot gets removed -->
clearinterval(calc('crop_anim_' + caller.name));
);
);
</action>

Thank you so much!

2

Tuesday, June 12th 2018, 4:08pm

Hi all, any turn back? If someone out there could help Please do, I have an urgent project that depends on this! Thank you

Tuur

Sage

Posts: 3,124

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

3

Tuesday, June 12th 2018, 6:17pm

Hi,

something like:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
	<action name="do_crop_animation_reverse" scope="local" args="framewidth, frameheight, framerate">
		calc(local.xframes, (caller.imagewidth /framewidth) BOR 0);
		calc(local.frames, xframes * ((caller.imageheight / frameheight) BOR 0));
		def(local.frame, integer, get(xframes));
		
		calc(caller.crop, '0|0|' + framewidth + '|' + frameheight);
		
		
		setinterval(calc('crop_anim_' + caller.name), calc(1.0 / framerate),
			if(caller.loaded,
				if(frame GT 0, dec(frame);, set(frame,calc(xframes -1)); );	
				mod(xpos, frame, xframes);
				div(ypos, frame, xframes);
				Math.floor(ypos);
				mul(xpos, framewidth);
				mul(ypos, frameheight);
				calc(caller.crop, xpos + '|' + ypos + '|' + framewidth + '|' + frameheight);
			  ,
				 stop the interval when the hotspot gets removed 
				clearinterval(calc('crop_anim_' + caller.name));
			);
		);
	</action>
	


not sure if it is perfect but seems to work quite ok.
http://www.virtualtuur.com/krpano/animatedhotspots/reverse/

btw if you have bigger, multi rows or column sprites i made a script for that.
https://krpano.com/forum/wbb/index.php?p…d&postID=56502&

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

This post has been edited 1 times, last edit by "Tuur" (Jun 12th 2018, 6:29pm)


4

Tuesday, June 12th 2018, 9:17pm

Thank you tuur, it works fine I had just to manage the code a bit to fit my needs! *thumbsup*