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
Related
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)
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?
I am very very new at java (as in, I took one beginner course) so please don't get super technical when answering me.
Earlier today I learned how you can load an image in java and display it in an applet.
I found a step-by-step youtube video that helped me do this.
Now I want to know how I can load an animation in java. Is that something that can be done? And can I get step-by-step instructions on how to do it? Basically, I already have a short .wmv file and I would like to display it when I run the program.
It also has audio that I would like to play along with it.
(i'm actually trying to make a video game with an animated character. java can be used to program games, so this should be doable, right? i don't care about making a game the "right" way or the way game developers usually do it, right now i just want to figure out the simple task of displaying an animation in java.)
thanks!
First of all, the wmv extension stands for video, and an animation is not a video. Its either a spritesheet, a gif image ect. In order to create a even simple animation, you must first learn some basic object oriented programming, become comfortable in creating and using classes, than you can advance to making your own class for taking care of sprites and cutting an image in a way that you can use it ect.
Example of a simple spriteshet:
This spritesheet is an simple image showing you one way to implement your 2d animation. You just have to cut the image parts from it using some rectangles. For 3d, you must use some other software and you must know that they use different kinds of extensions.
I wont dive into code, for the simple reason that I do not have time right now, but if you want further help, give my some contact like skype, facebook ect, I would love to help.
You could try the Java Media Framework javax.media.*. (caveat: rather old framework)
It appears you simply need to embed a media file such as video or audio into an applet. This can be achieved through a player embedded into an applet, similar to an individual frame or a .GIF file, that would be able to handle the .WMV extension.
Assuming awareness of the basic structure of a Java program, the main declaration to get an instance of a player is of the generic form, after:
player = Manager.createRealizedPlayer( mediaURL );
or
player = Manager.createPlayer( file.toURL() );
Good idea to go through the JMF documentation.
I am having a problem with manipulating images in java 7. I have researched the problem I am having for three weeks and have failed to find a solution,
I am trying to set an image over an area, basically setting the corner posistions.
I am using a BufferedImage.
This is for a 3D game where I am writing the 3D conversion code. I have managed to create a 3d world, and populate it with cubes, filling in the sides with graphics.fillPolygon():
What I would like to do is draw an image that fills a polygon's shape.
Any help I will be grateful for (even if it is formating this post better).
You can use transformations on your graphics. Here is a little tutorial on it. With that you can transform already drawn stuff. If you want to transform multiple images in different ways, you can draw them on different canvases and transform then separately. Then you can merge the images together...
But I would recommend using a 3D engine (JOGL, jMonkeyEngine, or others) for that (unless you want to learn about the geometric calculations with this task). It is also much faster to use OpenGL than drawing the stuff by yourself and doing the calculations in code (most probably meaning: on the CPU and not the GPU).
Have you tried using the drawImage? instead of .fillPolygon?