Sie sind nicht angemeldet.

1

Montag, 4. Juli 2011, 11:07

Looking for a simple way to tween a plugin to center of stage

Say you've got a square image plugin tucked in a corner of the screen, so just the edge is hanging out - you click on it tweens to the center of the stage (screen)... click it again and it goes back to its corner... I'm sure it's easy, I just can't figure out the syntax... something like: ???




Quellcode

1
	freezeview(true);set(hotspot.visible,false);tween(plugin[image].x,(screenwidth,0.5),0.25);tween(plugin[iamge].y,(screenheight,0.5),0.25);

Zephyr

Profi

Beiträge: 1 003

Wohnort: Netherlands

Beruf: Web developer

  • Nachricht senden

2

Montag, 4. Juli 2011, 12:05

try

Quellcode

1
2
3
4
5
div(halfscreenheight, screenheight,2);
div(halfscreenwidth, screenwidth,2);

tween(plugin[image].y,get(halfscreenheight),0.25);
tween(plugin[image].x,get(halfscreenwidth),0.25);

3

Montag, 4. Juli 2011, 12:27

Hi,

it would be also possible to use the the changeorigin action of the plugin for that,
this action changes the align and edge settings by keeping the current position,
so it would be possible to move at the center of the new align point just by tweening the x/y coordinates to 0,
e.g.

Quellcode

1
2
3
4
5
6
<plugin name="test"
        url="test.png"
        align="leftbottom"
        edge="center"
        onclick="if(align == center, changeorigin(leftbottom,center), changeorigin(center,center)); tween(x,0); tween(y,0);"
        />


best regards,
Klaus

4

Montag, 4. Juli 2011, 21:06

Thanks Klaus - worked perfectly!

Is there a reference you could point me towards regarding a better understanding of how to create the argument in the onclick? I'd like to better understand the construction of the argument, the "==", and subsequent (), and how to create my own arguments - I can change the variables, but I'd like to have a better comprehension of the argument construction... does that make sense? Thanks in advance!

5

Montag, 4. Juli 2011, 21:24

Hi,

there are no arguments or parameters in the onclick event itself,

see here the documentation of the if() action:
http://krpano.com/docu/actions/#if

in the example code above only the local attributes (align,x,y) of the <plugin> element were used (compared/changed),

there the current value of the "align" attribute of the current plugin element was compared with the value 'center',
and if that comparisons was true or false the "changeorigin" action was called to change the "align" and "edge" settings of the current plugin to other values,
and after the if() the tween() actions were called to change/animate the x,y settings of the plugin to 0.0,

best regards,
Klaus