Animation sinusoid in android - android

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.

Related

Android Drawing Moving Lines

I am developing a game using Android Studio where I need the blocks to move from right to left. I have a file as an input and it contains a string list which would look something like this:
[(160,0;7,58), (160,0;7,59)..]
The elements in this list should be seen as coordinates, the 1st number of each pair (in this case 160,0) is the coordinate on the Y axis and the second number (in this case 7,58 and 7,59) is the coordinate on the X axis
The idea of this list is that the first number of every pair is the pitch heard at that ms, which is the second number. And the lines that come in from the right should arrive at the left corner at the time they were heard.
Lets say I someone said one word (with the same pitch for this example), the list would look something like this
[(160,0;5,50),(160,0;5,51),(160,0;5,52),(160,0;5,53),(160,0;5,54),(160,0;5,55),(160,0;5,56),(160,0;5,57),(160,0;5,58),(160,0;5,59),(160,0;6,00),(160,0;6,01),(160,0;6,02),(160,0;6,03)]
Now in this given list the 160,0 is the pitch of the sound and the second number is 5,50ms. Now the idea is that the lines/bars that come from the right side will reach the left side at that point. This whole list makes one word and should be displayed as one block/line that moves from right to left.
The blocks should come in and then disappear (like it is illustrated in the illustration), pretty much like rainfall or in tetris where the blocks fall down but instead of hitting the ground they disappear. In the illustration you can see one full block and the other one is just coming in from the right. The 1st long block that you see in the illustration should move to the left most screen and then gradually dissapear.
I drew a little illustration of how it should look like : https://imgur.com/a/3X1dV
Is the best approach to create one block, clone it and move it on or draw new lines with "draw" or can someone tell me how I should approach this.

How to clear the detection using on-screen buttons?

Basically, I want to be able to clear the augmentation using the X button on the top-left corner of the screen, as shown in the picture.
This was done using some script in Unity3D.
Any idea how this is done?
Here's the link to the video: https://www.youtube.com/watch?v=9tksyhVlIMQ
These are my findings:
If you want on-screen buttons, then just parent the button UI to the Camera and position in a particular corner of the screen or something.
Now if you function it to work like if pressed and you want to clear or start detection use these:
TrackerManager.Instance.GetTracker<ImageTracker>().Stop();
TrackerManager.Instance.GetTracker<ImageTracker>().Start();
Took me a long time to figure this out. Hope it helps someone out there. :)

How to deal with overlapping RotateAnimation-s on Android?

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

Android rotating dialer set clickable area

I was just playing with Android SDK Demos and I found the rotating dialer example which you can find here : Android Rotating Dialer and I'm curious about one thing. How can I set the image to rotate only when I click on image..not inside in or out. I don't want to rotate it if I click at the center (in white area) or outside of the image (again in white area).
Any suggestions how can I achieve this?
Interesting question.
This would be possible by modifiying the code of myOnTouchListener. Just before the switch statement you would perform a calculation to check whether the x,y coords of the touch were outside an inner radius and inside an outer radius.
Some simple Pythagoras and it wouldn't be too hard. If this was not the case then return true at that point.

I need to move an image dynamically,depending upon the input from the user..What should i use?

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).

Categories

Resources