LibGDX TextureRegion draw bug when using split method and scaling - libgdx

I get a graphical glitch whenever I try to split my tileset into a TextureRegion[][] and drawing them. It works fine when I am using the default aspect ratio but when the window has to stretch, it seems to be accessing a line of pixels from the next tile in the tileset and drawing them. Here is a picture (The lines I am referring to are the 2 vertical brown lines in the water. They seem to be from another tile in my tileset):
The lines also move when I move the player. And when I run the game on my tablet, a similar effect happens except its the bottom layer of my player's feet that appear above its head.
I saw a similar problem in stackoverflow (stackoverflow.com/questions/285...) but the solution did not work for me. It said I should put a padding but that just makes the lines transparent and you see the background color.

Here is the solution I found. Someone on stackoverflow asked a similar question and they got a working response. They made a tile bleeding fix method. Here is the post: White vertical lines and jittery horizontal lines in tile map movement
Credit to grimrader22. Thanks a lot!
Thanks everyone else who helped get me on the right track to getting the solution.

As you said, the usual solution is to add a padding.
The padding should be of the same color as the border of the tile. For example the water tiles should have a blue padding and the sand a yellow one.
That way you won't get the transparency and it will be seamless.
Hope it helps.

Related

Rotate border of a line

I need some help as I am very new to coding. I am trying to design a website with a Website Builder (Homepage Baukasten) and I had to rotate a line through code as you can see on the image. The problem is now that I don't know how to transform its border (the white horizontal square) so I can place it where its supposed to go. I looked around to found a way but I did not found anything that did the job.
Thank you for your time and have a nice one!

Not able to animate SVG the way I want

I'm pretty new to SVG and how to work with them. I am not asking you for answer code, what I am asking is for some guide on maybe some plugin, maybe an article or some advice on how do I go about animating this SVG the way I wish to.
Problem:
I want to animate the picture below of the Sun, I'll be creating a vector graphic of this image obviously but what I want is these cuts in the bottom part of sun to animate and go from top to bottom revealing the background and second sun behind the main sun.
I want to do this inside a webpage so I need help regarding that.
Like I am not able to figure out how would I go about the whole process of making these cuts going down. Any help would be highly appreciated.
I would try https://rive.app/
As far as the how, I would create a short infinite loop. The horizontal bars would probably need to be their own shapes with some kind of masking effect on them to knock out the circle. You'd have to tween them to move up on the Y axis and let the height shrink to nothing as it moves up. The animation would probably only be 250-750ms. Let me know if that works!

Box2D Lights Wall Shadowing

Alright, so I've been pondering over this for quite awhile now; looking through documentation, examples, previously made games, ect...
Basically (for those familiar with Box2d Lights), I'm trying to create bodies on top of my walls (so there's shadow casting, and so the light will stop instead of going through the wall). I have no problem creating, positioning, and updating the bodies, but the only real problem which I can't figure out is a way to make the filled body to be invisible or transparent so it shows my tileset (or wall) while still giving a shadow effect if light was casted onto it.
Perhaps I'm thinking or going about this the wrong way. Feel free to correct me.
Here's an image to display an example of a body I created on top of my wall. The shadows are handled properly, but I cannot see my wall.
Any help is greatly appreciated. Thanks.
You have two options here:
Set the shadow-dropping bodies behind the wall and use only transparent bodies for collision detection using BitMasks
Or render your wall sprites on top of box2dLights

AS3 Fisheye Effect

I'm having trouble understand how DisplacementMapFilter works. Basically, I'm trying to create a revolving planet through a combination of fisheye/masking.
Also, how do I go about doing this via timeline? I'm not too familiar with coding within it, but this is more of an animation project than anything else, so classes are out of the question. Sorry for the lack of code -- I'm simply stuck.
As noted in the comments above, this probably only answers half the problem;
Generating a displacement map image isn't too difficult with the right tools. I'll assume you're using Photoshop, GIMP, Fireworks, or similar.
It's probably best to work on a 128x128 image or smaller with this method. Some editors have more specialised tools which let you work on pretty much any size of image, but this is a generic process that needs no special tools. You can always enlarge the end result, but the quality will begin to go down.
Start with a gradient fill. It should go from pure black on the left to dark red on the right (specifically 128,0,0). Add a vertical fill from black at the top to dark green at the bottom (specifically 0,128,0), and combine them with a LIGHTEN or ADD filter. You should now have an image which has black, red, green and yellow corners. Flatten it.
Copy this image to another layer / whatever the term-of-choice is for your editor. Apply whatever displacement filter you want to it (maybe a fish eye, maybe a manual smudge, maybe a perspective transform, anything)
Add a third layer between the two. Flood-fill it with dark yellow (128,128,0) and set it to ADD / ADDITION blend mode. Set the top layer to SUBTRACT / SUBTRACTION blend mode.
That's it. You should get a mostly yellow image which will function as a displacement map.
Update:
To use this in the example program (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filters/DisplacementMapFilter.html#includeExamplesSummary), replace the createBitmapData function with this:
private function createBitmapData():BitmapData {
return myBitmapObject.bitmapData;
}
where myBitmapObject is the instance name (I think) of your displacement Bitmap. There are tidier ways of setting that up, but this is the easiest.

HTML5 Canvas - Animating color, scale, and rotation

I'm new to canvas, so pardon the beginner question. I'm trying to animate a square on a canvas that changes colors, rotates, and scales up and down (this is just for practice). I'm just trying to grasp all of the concepts and create an example that does all of them at once.
What I want it to do is scale up to a certain amount, then once it reaches that amount, it scales back down to the beginning amount (and then repeats). The same goes for the color (continue animating, then go backwards through the colors). How can I accomplish this?
Here's an example of my code that I wrote:
http://jsfiddle.net/ggsFJ/1/
You'll notice a couple bugs:
Once the color gets to yellow, it stops animating.
The scaling obviously doesn't work.
The rotation isn't either clearing the canvas fast enough or something, because it's showing a trail of positions.
Where can I find some resources on accomplishing this? Any help is appreciated.
There's one small problem that's causing all the other problems (well, apart from the yellow - I'm not experiencing that particular one):
ctx.restore;
That line does nothing. You need to call ctx.restore using parentheses. Once you do that, the scaling works, and clearRect() will clear a non-transformed rectangle:
ctx.restore();
And here's the updated demo.
The problem I can see is with your restore method call.
You are just saying ctx.restore (possibly by mistake). It should be ctx.restore();