How to make UISlider stepless - swift

I am wondering if there is a way to make a UISlider move smoothly like the one in music App. Without steps and jumps. Just move till the end. I am currently using CADisplayLink to update the slider, the only problem is that the slider just jumps to the next value even when animated is set to true. This looks bad with values under 2min.

I am a bit confused by your question, but if your slider is very erratic and jumps to values the user did not set, I would recommend increasing the size of the element on your view controller.
If that doesn't work, you could scale your minimumValue and maximumValue by a factor of ten and then divide by ten when actually doing calculations with your UISlider. What I mean by that is:
multiply min and max values by 10
Keep a variable of the actual value you want to use
Save your value and divide by 10 whenever the user sets a new value in the UISlider

Related

How to get rid of acceleration during bouncing ? (unity 2D)

I don't know if this is the correct therm, but I want to get rid of any kind of forces that could modify the speed of my object. Let me explain : the game is 2D top-down view and the character fires a bullet that bounces x amount of time, WITH CONSTANT SPEED. Everything works fine, but when the bullet bounces fast and many times, its speed increases.
Also, second problem: I have a rotating object and when the bullet hits it, its speed increases (which makes sense, but I would like to know if there is a way to delete this effect) .
I would like to know if there is a way to solve my issues.
You need to check the material of the object for your first question (https://docs.unity3d.com/Manual/class-PhysicMaterial.html) you need to set Bounciness to 1 so it will maintain dame speed. If you set it to 0 there will be no bounce and probably you have a value bigger than 1 and so it's increasing.
In the second case it's all about the forces involving. The object bouncing on the rotating one is adding a force to that one. If you want to keep the second one with same rotation you could rotate it with a transform.Rotate and remove a Rigidbody or set it to static

Gradually decreasing the velocity of an object through animation in Unity

I need to create 2 animations,
one is of an object going from point A to point B at a constant velocity.
the other is of an object starting from point A but with a gradually decreasing velocity as it reaches point B until it comes to a stop.
I tried decreasing the animation speed every second to achieve this result with no luck.
Any ideas?
As you may have noticed when you work with animation in Unity there is no such thing as changing the velocity of an object. What you need to do is give your object an Animator and create a new Animation.
Then on the animation timeline press the red dot (record button) and then place your object on point A.
Next, on the time line you want to select the exact second that you want your object to come to a stop and after that move the object on point B.
Now, the more seconds there are in between the 2 keys, the more time it's going to take for the object to travel.
To make it gradually slower instead of it just travelling slowly:
On the animation panel you will see 2 tabs. Dopesheet and Curves. Hit Curves and play around with them till you have a satisfing result.
Documentation on using Curves

iOS - how to adjust the scale of a slider

I have an app where I want to place an object within a photo and scale it to reflect the distance it should be from the camera. At full size I want it to reflect approximately 10 meters away from the camera and at its smallest size I want it to be about 30 meters away.
Unfortunately, the slider seems to scale it almost infinitely, without looking very realistic in scaling. What's the best way to accomplish this such that I get both minimum and maximum distances as well as making intermediate distances scale in a realistic fashion (i.e., each intermediate step reflecting the actual distance it should be from the camera)?
By default UISlider's minimumValue and maximumValue are 0 and 1, respectively, which might explain the scaling behavior you're seeing. You can configure these values to simplify your calculations or, alternatively, scale the default 0-1 range to 10-30 meters.

animate the increasement of a score

SO I have a label labelscore and it increase of 1000 every time there is a collision between two images. I would like to see labelscore increase of 1000 like an animated score, a running score. How can I do this?
You can use an NSTimer to call a routine every 16.7 to 50 milliseconds. In the routine increment some value and update it to the label. Rinse and repeat until this value is equal to the score. This is the basic technique of an animation game loop.
You have the option to use a repeating timer and invalidate it when you're done with it. Or setting single-shot timers within each update routine for the next iteration. You could also use CADisplayLink as an alternative to NSTimer, which may provide smoother animation under some conditions.

Is there a way to set the number of animation steps for CABasicAnimation?

I want to create an animation that interpolates some property for 2 seconds and only 20 frames (presentation layers) have to be generated by the CoreAnimation framework. I know how to provide a duration for the explicit animation but which property do I have to change in order to get particular number of frames calculated by interpolation process?
Thanks in advance.
Core Animation works by using interpolation--calculating intermediate values in between key values you specify. If it's a keyframe animation, it interpolates between the number (n) of values in your values array. If it's a basic animation, it interpolates between two values--your start and end values. If you just want to change the frame rate of the animation instance go through this How to change the frame rate of a core animation instance?
What you want is not possible with Core Animation. The number of times it draws your layer is based off your program's frame rate.