PDA

View Full Version : Play animation on button press



Blalien
30 Jun 2011, 6:32 AM
Hello

I have a question regarding the animations.
Is it possible to play an animation from a scene after a button press?
I want to build a verification system so that it shows a message when incorrect.

So the utility starts, it plays a few animations then it stops. You enter something like your name, the system checks it and plays the last animation when incorrect. When correct it will send you to the next scene.

I know it has to be done in javascript but maybe someone can help me?

Thanks.

arnebech
30 Jun 2011, 4:32 PM
This is not currently supported in animator.

I don't have time to go in great detail, but here is a possible solution that might work. In animator give one animation object a custom css id (in the object->general properties panel) such as "verification-failed". Then in your exported code you'll find something that looks like this:


.run #verification-failed {
-webkit-animation-name: AN-ani-2;
-webkit-animation-duration: 1.6409090909090909s;
-webkit-animation-delay: 0s;
-webkit-animation-fill-mode: both;
}


you can change ".run" to ".verificationDidFail" then in your js code you can add the "verificationDidFail" class to a parent object of the animation (e.g. body, parent div etc..) which should trigger the animation when you had a failed verification.

In Ext you could do something like this


function playVerificationDidFailAnimation() {
var aParent = Ext.get('id-of-some-parent-div');
aParent.addClass('verificationDidFail');
}

Blalien
6 Jul 2011, 5:24 AM
Sadly I can't get it to work.
Used CSS with transitions instead.

Is there a way to stop the animation and remove it from the cache or someting?

arnebech
6 Jul 2011, 8:45 AM
The animations are specified in css, so you can simply remove the css class that causes the animations to run, or add a another class with animation that overrides the default one.