cocos2dx 2.x 屏幕适配问题

    xiaoxiao2021-12-14  45

    在CCEGLViewProtocol.h中提供方法:

    virtual void setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy);

    其中前面两个参数即为当前解决方案的长宽,第三个参数定义如下:

    enum ResolutionPolicy

    {

        // The entire application is visible in the specified area without trying to preserve the original aspect ratio.

        // Distortion can occur, and the application may appear stretched or compressed.

        kResolutionExactFit,

        // The entire application fills the specified area, without distortion but possibly with some cropping,

        // while maintaining the original aspect ratio of the application.

        kResolutionNoBorder,

        // The entire application is visible in the specified area without distortion while maintaining the original

        // aspect ratio of the application. Borders can appear on two sides of the application.

        kResolutionShowAll,

        // The application takes the height of the design resolution size and modifies the width of the internal

        // canvas so that it fits the aspect ratio of the device

        // no distortion will occur however you must make sure your application works on different

        // aspect ratios

        kResolutionFixedHeight,

        // The application takes the width of the design resolution size and modifies the height of the internal

        // canvas so that it fits the aspect ratio of the device

        // no distortion will occur however you must make sure your application works on different

        // aspect ratios

        kResolutionFixedWidth,

        kResolutionUnKnown,

    };

    google翻译一下:

    1. kResolutionExactFit:整个应用程序在指定区域中可见,而不尝试保留原始长宽比,可能发生失真,可能会显示拉伸或者压缩

    2. kResolutionNoBorder:整个应用程序填充指定的区域,没有失真,但可能有一些裁剪,保持原始长宽比

    3. kResolutionShowAll:显示所有内容,保持长宽比,会显示黑边

    4. kResolutionFixedHeight:保持height的数据适配,width会超出屏幕或者黑边

    5. kResolutionFixedWidth:保持width的数据适配,height会超出屏幕或者黑边

    6. kResolutionUnKnown:此版本不支持此参数。

    转载请注明原文地址: https://ju.6miu.com/read-963920.html

    最新回复(0)