cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.24k stars 7.06k forks source link

drawSolidPoly绘制一条粗斜线锯齿严重 #20625

Open lovelycheep opened 3 years ago

lovelycheep commented 3 years ago

Steps to Reproduce:

  1. 在demo基础上绘制一条斜线:

测试代码:

DrawNode* node2 = DrawNode::create();
Point p1(visibleSize.width/2 , visibleSize.height*2/3-50);
Point p2(visibleSize.width/2 + 150, visibleSize.height*2/3 -50 + 10);
Point p3(p1.x , p1.y + 10);
Point p4(p2.x, p2.y + 10);
Vec2 vecs[] = { p1, p2, p4, p3 };

node2->drawSolidPoly(vecs, 4, Color4F::WHITE);

addChild(node2, 5);

效果图如下:

41

请问哪位大神遇到过这个问题,或者有没有好的绘制斜线的方法

lovelycheep commented 3 years ago

求大神帮忙

lovelycheep commented 3 years ago

加上这段代码就好了

glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER); auto frameSize = glview->getFrameSize(); // if the frame's height is larger than the height of medium size. if (frameSize.height > mediumResolutionSize.height) { director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width)); }

为什么呢?