I am making a simple game on android. I want to make a map that would be able to zoom, so the images on it have to disappear when they left the screen. I want to put an image for background and put other images on it. The problem is that the images don't "stick" to the map, so when i zoom the background the images are still in the same place of the screen. I was looking for the solution in the internet, but i didn't find anything. I am writing in Android Studio in java.
Related
I have a PNG image (with transparent background) and I want to draw an outline around its visible pixels only. (See example GIF attached). I want to get this all done in JAVA.
I've read many Q&A over stackoverflow and around the web but I didn't find anything anyway near to my requirements.
P.S: We don't have to draw the same image twice on canvas and use the bottom one as outline, so please don't propose such solutions.
P.P.S: I would be great if this solution lets me draw an outline around all visible objects/elements (images & textviews etc) inside a canvas or inside a layout.
Try using Open CV and drawing contours. It is the closest available solution
I've been looking around for a simple way to put graphic on the screen in android for a while now and I'm really confused.
I've a simple game written in java with swing for graphics and that's all I really need as the graphics doesn't really matter in this project.
Now we want to rewrite it so it works on devices with android and honestly I can't find a simple way to just put a image on the screen.
I'd love to avoid using complex game engine because I just don't need it. All I want is a possibility to draw an image (or 50 images) on x,y given by me and refreshing a screen every 100 milliseconds and I thought I'd be the first thing I'd learn in any android tutorial but well... it's not. Of course I know how to draw an Image with .xml but I need something more automatic - for dozens of images changing all the time.
So what is the best to do this? Isn't there really any way to do it with just some android built in function? If not what engine should I use just for the simplest things I mentioned?
A simple but not necessarily very clean way to do this would be to create an xml layout that is just an empty RelativeLayout.
Then you could create your images like this:
ImageView image = new ImageView(this);
image.setLayoutParams(new RelativeLayout.LayoutParams(IMAGE_WIDTH,IMAGE_HEIGHT));
//Other setup code for your image goes here
myRelativeLayout.addView(image);
This should give you an image of the specified width and height that sits at the origin.
Then you could move the image into position like this:
image.setX(IMAGE_X_POS);
image.setY(IMAGE_Y_POS);
When to do the moving is up to you as it will depend on when you know the positions that need to be moved to.
I've seen this specific animation in certain apps where when scrolled, the first item on the window (most commonly an ImageView) gets faded out when scrolling down. Here's two screenshots that display the animated change:
This is from a fashion app named "Polyvore":
The image above displays an ImageView which gets faded out when scrolled. Animated more like.
And after scrolling a bit..
And it ultimately fades out along with the scrolling. Pardon me for I don't know what this 'View' or animation is called. I've seen this in the Google Play Music app as well. How do I implement this?
For anyone else looking for this specific effect. It's known as a Parallax effect. Check this link:
How to do the new PlayStore parallax effect
I'm trying to play gif animations on certain x,y coordinates.
i tried using the Movie class, but sadly most gif animations plays wired and not smooth enough.
In the Movie class i could simply set x,y coordinates of where i want my movie to be,
Now i want to use the GifDecoder class, but have no idea how to play it in dynamic x,y coordinates which changes all the time, and also make it seem smooth.
If you want to use GifDecoder, then here are some resources that I think might help you.
A tutorial can be found here.
Does it call scale? I need to use the zoomable function as what we do in browser with two finger. It seem zoom controls restricts alot on ImageView though. My images are in drawable, so i assume calling them through (R.drawable.myimage);
and btw im displaying my image with .setContentView(R.layout.myxml);