slycrel/JSTileMap

JSTileMap dropping first tileset column in Sprite-Kit when being scrolled.

Closed this issue · 4 comments

Please view sample project https://github.com/JRam13/JSGlitch.

Thanks @JRam13 I've been able to reproduce this and I'll look into what may be happening here.

Hi @JRam13. It took me a little while, but I realized that you are using a fork of JSTileMap that is not the one I am maintaining, but created by @fattjake for the platformer starter kit book. (I think the code can be found here: https://github.com/fattjake/JSTileMap)
Still, I'm interested to find out what's going on. I'll keep looking, but the problem seems to be in the following code.
screen shot 2014-08-02 at 7 05 47 pm
If you comment out line 698 you will see that that first column does not disappear. This is due to the offscreen culling that has been added. I suspect that this is a problem with the calculations in visibleTileCoordsInSceneAtPosition causing the first column to erroneously be seen by this code as off-screen and thereby hidden.
I'll let you know if I find a fix for this.

Okay, I have a workaround for you. Essentially this is making the sprite culling less performant and working around the problem rather than actually fixing it. Change the "else if" on line 704 to be an if that gets checked in addition to the code above it. Then change the conditions on this statement to be <= and >= (to be inclusive). This may, on large maps, draw an extra tile just outside of the bounds of the screen. But it also fixes the problem you are seeing.
A better fix would be to change the if that checks to see if a tile should be hidden or not. The above code simply un-hides a hidden tile that had been right on the line and hidden before.
Hope that helps some! I'll attach a screenshot of my changes just in case that wasn't as descriptive as it should have been.
screen shot 2014-08-02 at 7 39 26 pm

Excellent work. I didn't notice that I was using an old version. I went ahead and updated my project with your version and everything seems to be working fine- no more weirdness. By the way, great job on this tool, it's a must have for sprite-kit (until they come out with something native).