I am trying to implement a physics-based translation animation similar to the shown in the Android docs. I need a smooth change in velocity exactly same as in the example below. I searched online docs and tutorials but no way to find the shown example. Could you give sample android java or kotlin code to generate this smooth velocity change animation? I have tried FlingAnimation and SpringAnimation.
What you're looking for is time interpolation (or easing interpolation). You can create animations with different interpolators that can replicate real motion, for example a bouncing ball.
The animation you provided most likely is using a DecelerateInterpolator.
There're many interpolators and you can also create your own. There are plenty tutorials on how to implement them.
See example:
Some xml based animations
Bounce animation example (programatically)
Related
Here is a scenario on which i done a lot of research on google but hopeless. the scenario is, i am going to develop a 2D game in which i want to use multiple backgrounds and i want to translate them as they are moving forward, it must look like one background is near and translating/moving fast and the other background is a bit far and translating/moving a little slow. the nearer background have almost full intensity and the farer background have a bit low intensity. you can say they have different transparency levels. the question is, how can i get this task done or is this possible to use multiple backgrounds.
any suggestion will be appreciated.
as an example, see the image of BADLAND game bellow.
I think as far as I got your question you want to put two or more images one over another. I mean if you are trying to overlap the multiple backgrounds and asking for it yes it can be done easily.
What you need to do is to use the FrameLayout. as
"FrameLayout represents a simple layout for the user interface of
Android applications. It is usually used for displaying single Views
at a specific area on the screen or overlapping its child views."
and then you can implements the animations on them and translate them You can find different types of translation over them.
Here is all about using the frame layout frameLayout1 framelayout2 and for animations and translation here are links. link , link2 , link3
I've been surfing the web for android animation, and all what I found was the XML ones (transition,scale,...) but these simple functions cannot create complex animation. So how can I do so?
For example, I want "fireworks" in my application, so how I can animate it?
Thanks in advance.
For something like that you'll need a pixel or vertex shader, written in opengl. There is a small example here on how to load one: Shader for Android OpenGL ES
But I'll guess you'll find more if you google Android pixel shaders or something like that. Do you have any concrete questions? What are you going to do?
We are developing simple arcade game for android now and we are interested in adding some visual effects to it. Like disappearing or appearing animation and so on. Is there a simple way to do it without OpenGL for example just using some improvements to ImageView?
You could use the BitmapFactory and Bitmap Class to perform simple manipulations on images. Check out the http://developer.android.com/reference/android/graphics/Bitmap.html for what you can do with this class. It supports simple stuff like reloading, fading out, creating ScaledMaps and manipulating images on the screen on basic level.
For some simple instructions and examples see:
http://developer.android.com/guide/topics/graphics/index.html
http://www.anddev.org/resize_and_rotate_image_-_example-t621.html
Chapter 6 in "Android Developers cookbook" : http://www.informit.com/store/product.aspx?isbn=0321741234
I've created a prototype for a 2d android game using the android canvas object. Unfortunately, the performance is suffering greatly due to the large number of bitmaps that need to be redrawn frequently.
I'd like to migrate the drawing code to opengl, but I have no experience with it, and I'm having a difficult time getting the views configured properly. I've tried a wide variety of methods, but I'm not sure if the view configurations were wrong, of if the drawing functions didn't match.
Since most of my touch events are based on the coordinates, I'd like to have the opengl canvas view's coordinate system match the touch event coordinate system if possible. This would allow me to reuse a lot of code and avoid a lot of coordinate translation.
Can someone provide code or a link to code that would accomplish setting up a view and drawing a textured element?
I do not know how this question got overlooked but if you want a light introduction to OpenGL ES then you should take a look here. It is pretty good an explains things slowly enough that it is reasonably easy to understand.
I need to draw some execution sequences for some real time systems scheduled using rate monotonic algorithm. The drawing has to be done using Java and it has to be very basic.
Do you a very simple way to do this drawing? Simpler than Graphics2D?
Thanks a lot!
The diagram I want to be as simple or even simpler as this one:
I would suggest you to try with Processing, which is able to do such things with Java in zero time.. home page here.
You can easily embed a Processing frame inside your app, but remember that they are based on AWT so they are heavy weight and don't like being overlayed (for example in a JInternalFrame)
By the way what you seem to want to draw is a Gantt chart right?
You can try with JFreeChart too (see demo here), it's quite customizable and works fine.. homepage here