Pixels are displayed differently

Pixels are displayed differently
0.0 0


Hi. I’m a coco2d-x newbie.

I have one kind of wondering.

auto node = Node::create();

for (int i = 0; i < 16; i++) {
	for (int j = 0; j < 32; j++) {
		auto pixel = AssetManager::getInstance()->getSprite(SPRITE::PIXEL);
		pixel->setPosition(Point(j*2, i*2));

The size of the sprite in the node is not uniform.
SPRITE::PIXEL is just 1x1 image.

Why happen? and How can I make it same size?

Thanks for your help :slight_smile:


Hi bulzipke,

If what you are referring to is that the red squares don’t appear to be the same size (and shape) then you are seeing an optical illusion. Hold a ruler up to the tops(bottoms or sides) of the squares and you will see that they all line up. They are all the same size.

It is a very persistent illusion. Even though I know the red squares are all the same size I can’t shake the illusion that they aren’t.

The psychology guys would be amused with it.



Thank you for your attention. But this is not an optical illusion.

You can see that the size of the picture is different if you enlarge the size of the picture.
I attached a more detailed screenshot.

In addition, this is an alternative code that does not use sprite.

float size = 0.94f;
float gap = 1.04f;

Size visibleSize = Director::getInstance()->getVisibleSize();
auto renderTexture = RenderTexture::create(visibleSize.width, visibleSize.height);

for (int i = 0; i < 16; i++) {
	for (int j = 0; j < 32; j++) {
		auto pixel = DrawNode::create();
		Vec2 coords[] = { Vec2(0, size), Vec2(size, size), Vec2(size, 0), Vec2(0, 0) };
		pixel->drawPolygon(coords, 4, Color4F::RED, 0, Color4F(0, 0, 0, 0));
		pixel->setPosition(Point(-35.5f + j*gap, -8.8f + i*gap));

Alan, Thanks again for your interest :slight_smile:


Solved it.

Just about NO_BORDER option problem :slight_smile: