How to interrupt animation when clicking? - easeljs

I'm starting to work with EaselJS, so I'm making a simple demo:
A circle jumps up when you click it and falls back down afterwards.
My problem: When I click the circle BEFORE it returns to begin position, it doesn't react. It only reacts after it's back to its begin position.
Share your ideas! :)

Try using the override property on Tween.get(). This will clear any existing tweens on the object.
createjs.Tween.get(target, {override:true}).to(...);

Related

Swift: Custom Slider (Slide To Unlock style)

I am trying to implement a slider in the known slide to unlock style from older iphones to perform an action inside my swift app. The Slider should change background color and change the text inside while dragging. When the user drags til the end, the thumbView should stick to the right side and wait for a confirmation (some event) coming in to finally present a new view.
The slider should look something like this:
First state
Second state while dragging
Third state after releasing
I have found a few things on the internet but nothing that comes close to what I want to do. How would I go about doing this? My guess would be a combination of views with drag events but I feel like there must be an easier way. Any Ideas?
Maybe a UISlider with a transparent track on a rectangle view with your text and color. You can set your image as the UISlider's thumb and receive events as the value changes and when the user touches and releases it.
You can use that to for example, animate the thumb back to the start when the user releases on any place except the end of the track. Also, you can set the slider's value from 0 to 1 and use it to calculate the color, so it changes smoothly.
When the user releases on the end of the track, you activate the activity indicator and start your process to present the next view....
Even though this is a possibility, I think I'd try doing a custom control using a pan gesture. It'd give you more control and you could for example choose how the thumb image animates when going back to the start on release.... I dont' think you can do that with UISlider's setValue(animated:).

Creating a button in scratch

I am trying to make a multiple choice quiz in Scratch, but I am having trouble with coding the buttons. I have created the buttons, but I do not know how to get them so the users can click on them to choose answers. How can I get them to work?
Here is a screenshot of the code and the actual quiz.
You're currently using the TOUCHING SPRITE block. This block is for when the sprite itself is touching another sprite.
If you go into the code for each button, you'll find a hat block: WHEN THIS SPRITE CLICKED.
You can take this block, and have it set a variable with which block was clicked.
So in each of the button sprites you'd have something like this:
WHEN THIS SPRITE CLICKED
SET (ANSWERSELECTED) TO [A]
Then in your person sprite, where you currently have TOUCHING SPRITE 2 etc, you can have a variable that contains the answer selected. You'll want to clear the variable each time a new question is asked, e.g., set it to blank.
So you'll end up with something like this:
That's probably the simplest way.
IIRC, if you don't want to put scripts in the button sprites, you can also hack something together with something like IF MOUSE DOWN AND MOUSE X = (here you'd need to hack together the location of the button, probably using a AND block and using the X location of the button on both ends (which you can find using the mouse, under the player shows the current X and Y positions of the mouse)) AND MOUSE Y = (same as with X) SAY CORRECT FOR 3 SECS, but that's more difficult.
(That will require that the mouse be on the exact center of the button, though, so if you want to do it that way you'll probably want to account for being slightly off the center.)

Trigger like $EVT_PARK but when slide change starts

I am using $EVT_PARK to change captions but this only triggers when the slide change has completed. I would like to fade between captions during the slide movement. I can build that but need a trigger to activate when each slide change starts rather than finishes. Many thanks for any suggestions.
Please use $EVT_POSITION_CHANGE.
You will get actual position.

How to make an animation clip on Unity to loop

I am using the Unity Mecanim, and I have two animation clips:
The problem is that when the animation of a clip finish it doesnt start again from the beggining, it doesnt loop, and I cannot find any option to make it loop.
Any help, where to look for the loop options?
EDIT:
I find the options according to the answers here but there are not editable, is it because I download this from Asset Store?
Its probably too late to help you with this, but just incase anyone else has this issue, your looping options are greyed out because your animation from the asset store is read-only, select your animation in the project window, and press Ctrl+D to duplicate it, and you should be able to now set the looping options on the new animation as the other answerers have described.
Click on your Run_Impulse animation file and there is an option:
http://docs.unity3d.com/Documentation/Components/class-AnimationClip.html
Loop Pose option should be cheked for make it loop
Here, there is more information about making loop an animation clip:
http://docs.unity3d.com/Documentation/Manual/LoopingAnimationClips.html
EDIT: I add an image. You have to select your imported FBX (not the animation file inside) and check the Loop Time.
http://answers.unity3d.com/questions/204331/animation-loop.html
Go to the animation and set it as looping .In the Animation window look at the bottom for something that should say 'Default' - it's a drop-down menu with looping options (Loop starts the animation over, PingPong plays it back and forth, Clamp Forever freezes the animation at the state of the last frame etc.)

How do you return draggable content to their original positions in iPhone dev?

I am wanting to create a button in my iPhone app that when touched will return other draggable elements to their original position. I have looked at the Apple "MoveMe' example, but that returns the button to the center of the screen. I want to be able to position draggable objects around the screen, drag the objects within the app, and then return them to their original starting positions by pressing a designated button.
Any help appreciated!
Cache the initial positions of your draggable objects, and use an event handler on the button to reset their positions. I'm a little confused. The MoveMe example code is exactly what you need to answer your question -- what more do you want? You won't find a perfect code example for any arbitrary problem you can dream up.
Play around with saving the original positions and using MoveMe to reset the objects and I bet you'll have what your looking for in no time at all.