I am using RotateAnimation to animate pointing arrow that updates its position when of user updates destination point or current device position changes. I'm using interpolator.accelerate_decelerate to make animation look more smooth and "physical".
Everything goes fine until another update arrives when current animation is still processing, for example, when user changes destination while pointing arrow is still rotating. When such happens, the arrow makes a sharp bounce which looks ugly, and I'm trying to avoid this. I tried to implement a queue to make every next animation wait until previous ends and it looks nice, but behavior became quite illogical.
So my questions are following:
1) is there some way to make animated transitions more smooth in the cases when animations start one by one and overlap each other?
2) is there a way to stop animation that is currently processing and get intermediate position of an object?--if I decide to stop animation before its end and use current position as starting point for next animation.
ok so the easiest is to create a custom Animation similar to RotateAnimation and saving the current rotation angle in applyTransformation, this angle can be then used as a start angle for next Animation thus avoiding the "jumps"
A custom class extending ImageView that performs animation based on angular movement of dipole in magnetic field:
https://stackoverflow.com/a/22738030/3459206
Related
I am using this: CircularFloatingActionMenu
I have been able to use it so far pretty well. I am able to move it to desired positions as described in the ReadMe and even set rotation, theme coloring etc. My problem is I am trying to create a custom animation so that when placed in the upper right the icons shoot downwards. I kind of cheated and got it to appear to work by setting the start/end angle at 89 and 90 degrees so instead of being in a line they are just slightly off, but my problem is that when the animation finishes the final position ends up stacking all the icons on top of one another. I have attached screenshot demonstrating this.
Ive called my SlideDownAnimationHandler.java class as such:
FloatingActionMenu actionMenuTopRight = new FloatingActionMenu.Builder(this)
.setStartAngle(89)
.setEndAngle(90)
.setAnimationHandler(new SlideDownAnimationHandler())
.addSubActionView(rLSubBuilder.setContentView(rlIcon1).build())
.addSubActionView(rLSubBuilder.setContentView(rlIcon2).build())
.addSubActionView(rLSubBuilder.setContentView(rlIcon3).build())
//.addSubActionView(rLSubBuilder.setContentView(rlIcon4).build())
//.addSubActionView(rLSubBuilder.setContentView(rlIcon5).build())
.attachTo(darkButton)
.build();
I don't really want to post the SlideDownAnimationHandler.java classify as it is quite large (~100 lines of code). I'm wondering if theres a better way to properly animate the slide down effect, and also how to set their final position in a similar fashion to how i set the y translation in the animation itself.
I have an Android app developed using openGL and LibGDX.
Right now I do not know the strategy on how to code smooth transitions among a set of animations.
Example:
We have a cat actor.
Its animation consists of a set of key frames paired with transform matrix.
We have 5 preset animations for this cat:
idle, walk left, walk right, jump and lie down.
How can we transition from lets say
walk right => lie down
walk right => walk left
while the walk right animation is playing half way?
Right now once an animation starts, it needs to be played for 1 full cycle until the end.
This is so that the cat can move back into its neutral position.
Thus it can play the next animation which starts from a neutral position.
The final result is unnatural and jerky.
What approach should I use to tackle this problem?
Just starting the next Animation even when the previous one isn't finished is the Standard way. It looks good, do not wait for the first Animation to finish.
If you still think it looks unnatural. Then you must create a very fast "transition frame" between animations that makes it look more natural. Not worth the effort if you ask me, just try it the first way :)
I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?I have a problem with moving animation. I want to create animation which start when I to a screen and she starts from touched place and go to end place like on this picture:
The end place is constant. How Can I do this sinusoid movement?
edit1: I want to click and when i click, show image and he goes this way to end place. I don't click and drag this picture. This picture must shows and goes to this place without my help. Only what I do is touch the screen. How I can do that?
I wrote something like this that allows curved animation, you can see the full answer (and working code) here: Problem to achieve curved animation
It shouldn't be too difficult to either chain a number of those together, or modify the algorithm to use a cubic (or higher) function to produce multiple curves.
Only caveat is that because of the bezier curve, there is no guarantee the path will actually travel through the middle point you give it. If this is a problem again you could easily replace the bezier algorithm I use in the above example with something more suitable for your needs.
Check the sources of TranslationAnimation where the translation is done. Then build your function that maps the sinus function on the line from start to end. You could start with setting a horizontal line of with length dist(start,end) starting at (start), mapping sinus on it and then rotating it around your starting point.
Depending upon the user i may need to move it to right ,left,top or bottom.
Should i use animation for the purpose?
Or is there any method to move image dynamically?
I meant the things in android application
You use animation for a movement that has a distinct start and stop point. For example you might move the image right to left at a button push. It would slide a cross the screen and then appear back at its original position.
If you wanted to move things around this way you could do so by having 2 (or more) copies of the same view.. hiding the view at the old position and showing it again at the new one. You generally won't be stopping this animation between its begin and end point.
If you want some more interactive movement (say move along with the user's finger on the screen), you'll need to make use of the canvas and some touch listeners. In that case I recommend looking up drag and drop samples as they address what is needed for this to happen (and then some).
I have a simple translate tween that moves an object up 200 pixels. As soon as it's finished moving, it always bounces back to its original state and I don't want that. I want it to stay where I moved it.
I know this is should be an obvious solution, but I can't find the method/property anywhere to make it just stop and not reset...
Animation.setFillAfter(true) might be what you are looking for.