I am using the LibGDX orthographic camera class to handle different screen sizes and it works pretty well for me. The only issue I have is the border around the screen when the device doesn't stretch to scale.
I don't mind a border that much, the only thing that bothers me is the color of the border. I think it would look much nicer if it was black instead of white. Any way to change that?
Also I posted another question about android touch handling that was never answered. If someone could answer that, that would be great. I don't want to have to ask it again, I don't want to seem spammy. My Question
When your camera view is smaller than screen you probably just need to change clear color of GL.
glClearColor(r, g, b, a);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0,0,0,1);
Black clear screen. Thats all you need.
Related
I am creating a 2D game with lwjgl and slick-util. For a special feature in my game I wanted to be able to give textures a certain opacity. I have managed to figure this out but the next step is giving a Texture as a paramter which will give me the ability to give certain textures certain opacities in certain spots.
Note: I have gotten it sort of working before, but the mask also seemed to remove my background image, which I do not want.
I cannot post images because I dont have enough reputation or something but anyway what I want to basically do is:
first render a background image.
then render another images on top with a mask on it, I do not want this mask to apply onto the background.
How would I go about doing this?
I think you use wrong blending mode. If you did not change default blending mode, then you need:
glEnable (GL_BLEND); // Enable blending.
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Setup blending function.
I think in you case, texture does not blend with background, it simple replaces background.
I'm using SVG files in my Game and i want to add transparency and brightness effects to them. So what i want is that a sprite becomes more and more transparent until it's invisible. This looks much smoother than a just disappearing sprite. This allows also smooth transitions between the levels where a white screen gets less transparent and then again more. I hope you understand what i mean. Besides this a brightness effect would be nice, too. A sprite can get brighter or darker during the game. Nevertheless i could create a workaround for this using the transparency effect, but yeah, i have none :/
I use this library:
https://androidsvg.googlecode.com/hg/doc/reference/packages.html
I render my svgs on this way:
svg.renderToCanvas(pCanvas);
However i can also convert it to pictures:
Picture pic = svg.renderToPicture();
Maybe this information will help you.
Does there exist something what could help me? And if not, have you an idea how can i solve the problem?
EDIT:So iwant my SVGs behave like these ones:
http://scratch.mit.edu/projects/24634091/
You could use an ImageView and setAlpha(), as Frank says. Or it may just be easier to render the sprites to the canvas in your draw() method.
If you are writing a game, then you may find that rendering SVGs in your game loop may not be fast enough. So you might have to pre-render all your SVG sprites to Bitmaps (ie on startup) and draw them to your Canvas.
Paint p = new Paint();
p.setAlpha(alpha);
canvas.drawBitmap(sprite, x,y, p);
Can you modify the darkness you get on screen when using a ray handler in libgdx with box2d world? Also when I put lights over sprites they look different because the light is on top of them. Can you render lights so that the color of the sprite is the same, even though it is lighted up by a source?
Yes. You can modify the darkness by setting ambient light. For instance:
rayHandler.setAmbientLight(0.5f);
makes everything 50% brighter.
Also, if you find that the lights over your sprites cause too much of a difference in colour, you might want to set the light's colour to white and set the alpha lower (just tweak around with it until you think it looks good).
I am currently working on making a Java videogame with a few friends. It is a top-down RPG that is drawn with tiles of different types. I just added a day/night cycle to the game, and found that using transparent colors to draw to the screen is very slow. I recently learned how to make colors transparent by adding an alpha-value after the RGB values, and it works very well, but as I said, it is slow. I tried switching between transparent colors and opaque colors and discovered that the lag is because of the transparency. Basically, after a tile is drawn, it calls the method for getting the desired transparency factor, makes a new color, and calls g.fillRect() over the tile. This is done for every tile on screen.
I would like to know if there is another way to have a transparent overlay without just drawing the overlay over the whole window, because we want to be able to add light sources that replace the transparency for specific tiles. The tiles are drawn to the screen from a spritesheet. Any suggestions are welcomed.
I currently have a custom view whose color is set using the following,
canvas.drawColor(Color.RED);
What I would like to do a punch a "hole" in the now red background or essentially fill that hole with a transparent color. I would also like to invert this as well to my choosing. If anyone can shed some light on this topic, much would be appreciated. I've looked at this post erase bitmap but it seems overkill for what I'm trying to do here.
Have a look at the Xfermode graphics sample from Android.
This blog post has an example that uses the canvas.drawColor, but on top of an existing bitmap.