在AppDelegate::applicationDidFinishLaunching()中加了下面一行代码:
glview->setDesignResolutionSize(600, 800, ResolutionPolicy::NO_BORDER);
```
Scene* HelloWorld::createScene()的代码如下:
Scene* HelloWorld::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::createWithPhysics();
scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
// 'layer' is an autorelease object
auto layer = HelloWorld::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
```
在bool HelloWorld::init()中加了如下代码:
Sprite *edgeSp = Sprite::create();
auto boundBody = PhysicsBody::createEdgeBox(visibleSize, PHYSICSBODY_MATERIAL_DEFAULT, 3);
boundBody->getShape(0)->setRestitution(1.0f);
boundBody->getShape(0)->setFriction(0.0f);
boundBody->getShape(0)->setDensity(1.0f);
edgeSp->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2));
edgeSp->setPhysicsBody(boundBody);
this->addChild(edgeSp);
edgeSp->setTag(0);
```
按照NO_BORDER的属性理论上的效果应该是edgeSp铺满全屏,以最大比率为准,实际运行的效果却是edgeSp没有铺满全屏(附图中红色区域),不居中显示而是偏左显示,右边留出黑色区域,真是百思不得其解啊,是我理解不对还是哪里出错了?
把NO_BORDER换成EXACT_FIT或者SHOW_ALL却又都是预期的效果,我就不明白了,求大神解释一下。代码也一并传上来了
Classes.zip (5 KB)
