Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnimatedFloat.watch() doesn't work as expected #357

Open
macropp opened this issue Sep 25, 2015 · 0 comments
Open

AnimatedFloat.watch() doesn't work as expected #357

macropp opened this issue Sep 25, 2015 · 0 comments

Comments

@macropp
Copy link

macropp commented Sep 25, 2015

Hi,
I have an expandable panel which has a scissor applied to its Sprite. What I want to do is to animate the scissor height, for which I've created an AnimatedFloat and tried to create a watch function which will update the height of the scissor to animate the mask.

Code looks something like this:

var s:Sprite = // sprite from asset pack;
// s is then added to an Entity as a component
s.scissor = new Rectangle(0,0,100,20);

// creating animated float with the collapsed panel height
var animatedHeight:AnimatedFloat = new AnimatedFloat(20);
_heightListener = animatedHeight.watch(onHeightUpdate);

// then I try to animate the height
animatedHeight.animateTo(100, .15);

function onHeightUpdate(to:Float, from:Float):Void
{
    cast(/* get sprite */, Sprite).scissor.height = to;
}

Problem is that onHeightUpdate only gets called once, when the watch() is called. I've looked at the source of both AnimatedFloat and Tween, but everything seems ok there, so most likely I'm missing something. Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant