屏幕适配

梦想游戏人
目录:
Cocos2dx
.

//想了半天 还是自己解决好,资料全是没用的理论 屁话


class HeightFix :public Layer//屏幕适配 层
{
public:
	HeightFix()
	{
		Layer::init();

		auto up = Sprite::create("bg_bottom_all.png");
		auto down = Sprite::create("bg_bottom_all.png");

		this->addChild(down);
		this->addChild(up);
	
		up->setPosition(540/ 2, HEIGHT_MAX/2+810/2+197/2		);
		down->setPosition(540 / 2,HEIGHT_MAX / 2 - 810 / 2 - 197 / 2);
	}
};


/////


bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLViewImpl::create("SGZonline");
        director->setOpenGLView(glview);
		glview->setFrameSize(640, 1136);// 5S
		//glview->setFrameSize(640, 960);// 4S

		glview->setFrameZoomFactor(0.5);
    }

    director->getOpenGLView()->setDesignResolutionSize(540, 1204, ResolutionPolicy::FIXED_WIDTH);
    
    ........
Scroll Up