in my game (using libgdx) i use a scrolling background the scrolling Background it's work good for some backgrounds like this :
Good one
but when i draw my own background using inkscape or photoshope if i use a line in the sides of the background or something like shadow the probelm of a black line appear , except if i use a picture with one color and drawing in the middle . that's mean the problem is from the picture but why in the others background it's work good (There is no problem in the code and measurements)???
Appearance of a line
If code would be attached, would be great. But looks like, when drawing sprite, need draw one pixel less at the beginning, or draw one pixel more end in the end of sprite.
Related
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.
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);
I've used GIMP to create a sprite using a transparent background. Once I put it in the Image Packer the transparent background disappears and the whole image is messed up. After a bit of googling without finding a single useful thing I decided to use a pink background, but I can't find support for setting a pixel to alpha (I can read the pixel's color though!)
How do I fix this and have a transparent background in my sprite (org.newdawn.slick.Image to be precise)?
Useful links: None as far as I can remember. Took me 45 minutes to jump to this site for help, so there's either pretty much nothing or literally no support.
Are you sure the image is saved in a format that supports the transparency? For example JPG does NOT support transparency. PNG does.
Also are you sure that when saving the picture the background is indeed transparent and not white? To double check the background is transparent the majority of image editors will display a grey and white checked grids to show transparency.
I'm developing a JApplet in which the user can draw some lines over an image.
Lines can be red or green, but I need to highlight them because I don't know the background color.
So I thought that I can draw a white "border" to the line, and I tried to do this creating other two white lines to the left and to the rigth of the original one. But the result is poor.
Is there a better way to accomplish this goal?
As mentioned by #Jesper, draw the line first using a thicker Stroke (as seen in this answer).
The black outline on the letters has width 2.
g.setStroke(new BasicStroke(2f));
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.