TileMap and Zooming out issue, gaps.

Forums Programming cocos2d support (graphics engine) TileMap and Zooming out issue, gaps.

This topic contains 9 replies, has 5 voices, and was last updated by  tien1504 3 years, 1 month ago.

Viewing 10 posts - 1 through 10 (of 10 total)
Author Posts
Author Posts
February 24, 2010 at 4:04 am #220031

willf
@willf

Hello all, I seem to be having a strange issue. I have my tile map and it looks fine when the scale is 1. But when I try to implement zoom out functoinality and set the scale to say, 0.5. I get strange gaps.

My tiles are each 80 x 40. I set them to render without AA.

I have followed the tips and tricks section but nothing seems to work.

Here is what it looks like when scale = 1

This is what it looks like when scale = 0.5

One interesting to note is that there seems to be that cross section that has those gaps.. Almost like down the middle vertically and down the middle horizontally of the screen. This stays fixed in that location even if i move the map around. For instance if i move the map such that i drag it to the bottom right (or left) corner… the jagged gaps disappear.

Anyone have any insight into this?

(I’m using cocos2d 0.8.2)

February 24, 2010 at 9:05 am #274301

patrickC
Participant
@patrickc

This has been discussed a thousand times….

A search for the word “gap” returns lots of results:

http://www.cocos2d-iphone.org/forum/topic/4219

http://www.cocos2d-iphone.org/forum/topic/2654

http://www.cocos2d-iphone.org/forum/topic/73

http://www.cocos2d-iphone.org/forum/topic/2615

http://www.cocos2d-iphone.org/forum/topic/1821

And it’s also discussed on the tips&tricks page on the wiki:

http://www.cocos2d-iphone.org/wiki/doku.php/tips:generic

February 24, 2010 at 10:30 am #274302

gaminghorror
Participant
@gaminghorror

Have you looked into ccConfig.h and turn the subpixel rendering off (by default it’s on)? Maybe that helps.

February 24, 2010 at 12:55 pm #274303

riq
Keymaster
@admin

You can also try with:

CCTMXLayer *layer = [map layerNamed:@"layer0"];

[[[layer textureAtlas] texture] generateMipmap];

February 24, 2010 at 6:13 pm #274304

willf
@willf

Here’s a list of things I tried:

-Set 2d Projection

-tried the sprite-sheet-artifact-fixer

-when scrolling add a +0.5 to the position

-I am on 0.8.2 but I copied the generateMipmap method from the latest release and tried that

-I tried the RoundedUpdate category for MoveTo (even though I’m not using moveTo for the map), I did a quick test and added MoveTo action to the map, still the same

-when getting the rect for the tiles i added 1px to the width

-disabled sub pixel rendering

None of them worked. The one thing that made a difference was

glTranslatef(0.5f,0.5f,0);

[super draw];

glTranslatef(-0.5f,-0.5f,0);

If my map was in the center of the screen there would be no gaps, but if i move the map to the bottom left corner, the gap would appear again.

I am just setting the position. and using scale = 0.5f. Riq – i know in one of the other threads you asked if the person was using scale (they weren’t). Could you tell me what are the implications of changing the scale

February 24, 2010 at 6:36 pm #274305

riq
Keymaster
@admin

@willf: so you are using the artifact fixer, right ? Could you try using antialiased tiles then ?

CCTMXLayer *layer = [map layerNamed:@"layer0"];

[[[layer textureAtlas] texture] setAntiAliasTexParameters];

February 24, 2010 at 7:50 pm #274306

willf
@willf

Okay i tried setting AA and this is what I get

The strange gaps are no longer there but these blurred borders make the tiles not seem flush (the reason I originally had no AA in the first place was due to this issue). IS there anythig I could do programticcally to solve this issue?

February 24, 2010 at 7:57 pm #274307

riq
Keymaster
@admin

if the following worked for you:

glTranslatef(0.5f,0.5f,0);
[super draw];
glTranslatef(-0.5f,-0.5f,0);

Then, I would make sure that the map is always displayed in 0.5.

You can do it by subclassing TMXTileMap:

// TMXTileMap subclass

-(void) setPosition:(CGPoint)p
{
int x = p.y;
int y = p.y;
[super setPosition:ccp( x + 0.5f, y+0.5f)];
}

February 24, 2010 at 8:39 pm #274308

willf
@willf

glTranslatef(0.5f,0.5f,0);

[super draw];

glTranslatef(-0.5f,-0.5f,0);

What I meant before was that code made it behave slightly different. The gaps wouldn’t occur until i dragged my map to the left side of the iphone screen. where as before, when the map was in the center of the screen that gaps would show.

So i tried the position overriding and that didn’t change anything.

March 13, 2011 at 8:27 am #274309

tien1504
@tien1504

Hi, I also have the same problem with you, Willf. After trying using all of above ways, I didn’t still get it work. But it worked ok now when I tried re-creating my tileset with space and margin EQUAL 0. You should try this way.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.