Sie sind nicht angemeldet.

1

Dienstag, 12. Juni 2018, 04:02

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

Dienstag, 12. Juni 2018, 16:08

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

Erleuchteter

Beiträge: 3 839

Wohnort: Netherlands

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

  • Nachricht senden

3

Dienstag, 12. Juni 2018, 18:17

Hi,

something like:

Quellcode

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*

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Tuur« (12. Juni 2018, 18:29)


4

Dienstag, 12. Juni 2018, 21:17

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