Putting the same colored sprite next to each other makes visible the boundary of those spries with batch node

Consider that I have an PNG file for background sprite. I create two sprites with that image. And I put them next to each other like this:

Sprite * green_hills = Sprite::create("green_hills.png");
green_hills->setPosition(0,0);
green_hills->setAnchorPoint(Point(0.0,0.0));

Sprite * green_hills2 = Sprite::create("green_hills.png");
green_hills2->setPosition(green_hills2->getBoundingBox().size.width, 0);
green_hills2->setAnchorPoint(Point(0.0,0.0));

Sprite * green_hills_bg = Sprite::create();
green_hills_bg->addChild(green_hills, 1);
green_hills_bg->addChild(green_hills2, 1);
addChild(green_hills_bg);

This works fine!

The problem starts if I want to use batch node for reducing draw calls. First of all you have to create the green_hills_bg sprite with an image which is present in the sprite sheet, otherwise when you do m_spritebatch->addChild(green_hills_bg);, application crashes. Therefore I have added a one pixel sized dot into the sprite sheet and have done this:

SpriteBatchNode*   m_spritebatch = SpriteBatchNode::create("imgs.png");
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("imgs.plist");

Sprite * green_hills = Sprite::createWithSpriteFrameName("green_hills.png");
green_hills->setPosition(0,0);
green_hills->setAnchorPoint(Point(0.0,0.0));

Sprite * green_hills2 = Sprite::createWithSpriteFrameName("green_hills.png");
green_hills2->setPosition(green_hills2->getBoundingBox().size.width, 0);
green_hills2->setAnchorPoint(Point(0.0,0.0));

Sprite * green_hills_bg = Sprite::createWithSpriteFrameName("blank_dot.png");
green_hills_bg->addChild(green_hills, 1);
green_hills_bg->addChild(green_hills2, 1);
m_spritebatch->addChild(green_hills_bg);

But in this case I see the boundary between green_hills and green_hills2 sprites. Please see the first attached image below.

Another interesting thing is that this line disappears in some position of the container sprite and is some positions appears.

Also I have tried to overlap these sprites by one pixel, and I have another line between there two sprites (see the second attached image).

And this is not because of the scolling motions as far as I have captured images from the static states.


Capture.PNG (62.4 KB)


Capture.PNG (65.8 KB)

you use beta vesion?

Yes! Is this a bug of beta version?

I have the same problem…
there is a problem with the rendering in the batch node when you add a sprite as child, I do not know if it is a bug or something we are missing but my app was running fine (no memory leaks, fps ok, …) and since I’m running with beta version I have a lot problem (crash etc…)
Please read my post in beta feedback

I wanted to create parallax effect for infinitely scrolling backgrounds, when this problem occurred. First I thought this is because the scrolling motion, but then I have experimented and saw that in static states the boundary is visible too.

BTW, could you please write the link for you post to beta feedback?

P.S. Did you try this with a stable version. Does it work?

put you problem in the feedback so I’m not alone to push :slight_smile:

Two questions:

  • Did you try this with a stable version. Does it work?
  • How to put my problem in the feedback? Just copy past this posts link into that thread?

@fabrice I have found the problem. This was my fault. You need just to set Extrude to 1 in texture packer.

Also I have just found a good tutorial: http://www.matim-dev.com/texture-packer---get-rid-of-sprite-artefacts.html