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

Saturday, November 4th 2017, 10:57am

How to start an animation action on a hotspot sprite sheet from another hotspot ?

Hi,

These forums are very helpful. I believe, I have never been stuck on a krpano project and not found an answer here. Krpano itself is a genius piece of software and with the best help in this forum.

My question today is I have a sprite sheet that I am animating on a hotspot, which works fine:

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
25
26
27
28
29
30
31
32
33
34
    <style name="w_style"              
	url="skin/asst1b.png"                
	crop="0|0|77|153"              
	frames="7" framewidth="77" frameheight="153" frame="1" loopNo="19" loopCount="0"                
	column="1" columns="7" columnframenr="1"   
	onloaded=""                         
	altonloaded="if(isphone, mul(scale,2)); onloaded();"                
	scale="1.5"             
	edge=""             
	oy="0"              
	onclick="w_animate();"              
	distorted="true" 
    />



<action name="w_animate">       
	inc(frame,1,get(frames),1);         
	mul(t, column, columnframenr);      
	add(t,1);       
	if(frame == t, inc(column,1));  
	sub(xp, column,1);          
	mul(xp, framewidth);            
	mul(yp,frame,frameheight);          
	mul(ch, columnframenr, frameheight);            
	sub(cm, column,1);          
	sub(q,columns,1);       
	mul(ce, ch,cm);
	if(cm==q, set(column, 1));  
	if(yp GT ch, sub(yp, ce));          
	sub(yp, frameheight);                       
	txtadd(crop, get(xp),'|',get(yp),'|',get(framewidth),'|',get(frameheight));
	if(loopCount LE loopNo, inc(loopCount, 1);  delayedcall(0.08, w_animate() ); , set(loopCount, 0); );
</action>


Now when I am calling the hotspot in a scene it works fine too.

Source code

1
2
3
4
5
6
7
8
9
	 <scene name="" title="" onstart="" thumburl="" lat="" lng="" heading="">
	.
	.	.	.
	<hotspot name="asst_cursor" 
	style="w_style"
	ath="61.016" atv="-5.7"
	enabled="true"
	onclick="w_animate();"
	/>



But what I want is to call the animation on that hotspot after clicking on another hotspot and I cannot get my head around how to do that ... *wacko*
This part below is the problem:


Source code

1
2
	<hotspot name="spotOpt1" url="skin/buttons_yellow.png" distorted="true" scale="0.25" enabled="true" ath="45.382" atv="-0.911" 
					onclick="set(hotspot[asst_cursor].w_animate(); );" />



Thanks,
DarManiac



jeromebg

Professional

Posts: 784

Location: Angers - France

Occupation: Photographer

  • Send private message

2

Sunday, November 5th 2017, 5:31pm

call the action with the name of the hotspot you want to animate :

Source code

1
onclick="w_animate(name_of_the_hotspot);"


and in your action get this name with %1

Source code

1
2
3
<action name="w_animate">       
	inc(frame,1,get(hotspot[%1].frames),1);  
        ...

3

Monday, November 6th 2017, 11:38am

Hi Jerombg,

Thanks. I tried your suggestion but it doesn't seem to be working. Did I do something wrong... ??

Outside Scene:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
    <style name="w_style" 
        url="skin/asst1b.png" 
        crop="0|0|77|153" 
        frames="7" framewidth="77" frameheight="153" frame="1" loopNo="19" loopCount="0" 
        column="1" columns="7" columnframenr="1" 
        onloaded="" 
        altonloaded="if(isphone, mul(scale,2)); onloaded();" 
        scale="1.5" 
        edge="" 
        oy="0" 
        onclick="w_animate();" 
        distorted="true" 
    />



In Scene:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<hotspot name="spotOpt3" url="skin/buttons_yellow.png" distorted="true" scale="0.25" enabled="true" ath="45.382" atv="-16.911" 
                                                                                    onclick="w_animate1(asst_cursor);" />

    <action name="w_animate1"> 
        inc(get(hotspot[%1].frame),1,get(hotspot[%1].frames),1); 
        mul(t, get(hotspot[%1].column), get(hotspot[%1].columnframenr)); 
        add(t,1); 
        if(get(hotspot[%1].frame) == t, inc(get(hotspot[%1].column,1))); 
        sub(xp, get(hotspot[%1].column),1); 
        mul(xp, get(hotspot[%1].framewidth)); 
        mul(yp, get(hotspot[%1].frame), get(hotspot[%1].frameheight)); 
        mul(ch, get(hotspot[%1].columnframenr), get(hotspot[%1].frameheight)); 
        sub(cm, get(hotspot[%1].column),1); 
        sub(q, get(hotspot[%1].columns),1); 
        mul(ce, ch,cm);
        if(cm==q, set(get(hotspot[%1].column), 1)); 
        if(yp GT ch, sub(yp, ce)); 
        sub(yp, get(hotspot[%1].frameheight)); 
        txtadd(crop, get(xp),'|',get(yp),'|',get(hotspot[%1].framewidth),'|',get(hotspot[%1].frameheight));
        if(get(hotspot[%1].loopCount) LE get(hotspot[%1].loopNo), inc(get(hotspot[%1].loopCount), 1);  delayedcall(0.08, w_animate(asst_cursor) ); , set(get(hotspot[%1].loopCount), 0); );
    </action>

This post has been edited 1 times, last edit by "DarManiac" (Nov 6th 2017, 12:32pm)


jeromebg

Professional

Posts: 784

Location: Angers - France

Occupation: Photographer

  • Send private message

4

Monday, November 6th 2017, 1:35pm

what is the code of your asst_cursor hotspot ?

5

Monday, November 6th 2017, 1:42pm

Source code

1
2
3
4
5
<hotspot name="asst_cursor" 
            style="w_style"
            ath="61.016" atv="-5.7"
            enabled="true"
         />

jeromebg

Professional

Posts: 784

Location: Angers - France

Occupation: Photographer

  • Send private message

6

Monday, November 6th 2017, 1:56pm

<action name="w_animate1">
inc(get(hotspot[%1].frame),1,get(hotspot[%1].frames),1);
mul(t, get(hotspot[%1].column), get(hotspot[%1].columnframenr));
add(t,1);
if(get(hotspot[%1].frame) == t, inc(get(hotspot[%1].column,1)));
sub(xp, get(hotspot[%1].column),1);
mul(xp, get(hotspot[%1].framewidth));
mul(yp, get(hotspot[%1].frame), get(hotspot[%1].frameheight));
mul(ch, get(hotspot[%1].columnframenr), get(hotspot[%1].frameheight));
sub(cm, get(hotspot[%1].column),1);
sub(q, get(hotspot[%1].columns),1);
mul(ce, ch,cm);
if(cm==q, set(get(hotspot[%1].column), 1));
if(yp GT ch, sub(yp, ce));
sub(yp, get(hotspot[%1].frameheight));
txtadd(crop, get(xp),'|',get(yp),'|',get(hotspot[%1].framewidth),'|',get(hotspot[%1].frameheight));
if(get(hotspot[%1].loopCount) LE get(hotspot[%1].loopNo), inc(get(hotspot[%1].loopCount), 1); delayedcall(0.08, w_animate(asst_cursor) ); , set(get(hotspot[%1].loopCount), 0); );
</action>

should be

<action name="w_animate1">
inc(get(hotspot[%1].frame),1,get(hotspot[%1].frames),1);
mul(t, get(hotspot[%1].column), get(hotspot[%1].columnframenr));
add(t,1);
if(get(hotspot[%1].frame) == t, inc(get(hotspot[%1].column,1)));
sub(xp, get(hotspot[%1].column),1);
mul(xp, get(hotspot[%1].framewidth));
mul(yp, get(hotspot[%1].frame), get(hotspot[%1].frameheight));
mul(ch, get(hotspot[%1].columnframenr), get(hotspot[%1].frameheight));
sub(cm, get(hotspot[%1].column),1);
sub(q, get(hotspot[%1].columns),1);
mul(ce, ch,cm);
if(cm==q, set(get(hotspot[%1].column), 1));
if(yp GT ch, sub(yp, ce));
sub(yp, get(hotspot[%1].frameheight));
txtadd(crop, get(xp),'|',get(yp),'|',get(hotspot[%1].framewidth),'|',get(hotspot[%1].frameheight));
if(get(hotspot[%1].loopCount) LE get(hotspot[%1].loopNo), inc(get(hotspot[%1].loopCount), 1); delayedcall(0.08, w_animate1(asst_cursor) ); , set(get(hotspot[%1].loopCount), 0); );
</action>

7

Monday, November 6th 2017, 2:04pm

Thanks so much for the prompt response

I see w_animate1 error that i made. I still copied that entire block you gave just to be sure.

I tested it and what is happening is that the button I am clicking is getting cropped, but the other hotspot isn't getting animated...

jeromebg

Professional

Posts: 784

Location: Angers - France

Occupation: Photographer

  • Send private message

8

Wednesday, November 8th 2017, 10:43am

why not just calling the hotspot onclick action then, something like :
<hotspot name="spotOpt3" onclick="callwith(hotspot[asst_cursor],onclick())"/>

9

Wednesday, November 8th 2017, 2:21pm

Thanks Jerome ... You're brilliant.. It works... *smile* Thank you so much ... was whacking my head over this. I did not know how to use call with function...

Thanks,
DarManiac