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: ???


    Code
    freezeview(true);set(hotspot.visible,false);tween(plugin[image].x,(screenwidth,0.5),0.25);tween(plugin[iamge].y,(screenheight,0.5),0.25);
  • 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.

    Code
    <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

  • 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!

  • Hi,

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

    see here the documentation of the if() action:
    https://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

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!