#define NON_UNIFORM_SCALE 1 // 不等比缩放开关 宏定义
/*
修改create(int width,int height) / CCEGLView::setViewPortInPoints(float x,float y,float w,float h) / CCEGLView::setScissorInPoints(float x,float h)
方法中关于缩放的处理 */
)
{
)
{
;
}
;
;
// calculate the factor and the rect of viewport
;
#if NON_UNIFORM_SCALE
m_fScreenScaleFactorX
// 分别得到X,Y的缩放参数
m_fScreenScaleFactorY
;
#else
// 等比例缩放
;
#endif
;
;
;
;
;
;
;
}
setViewPortInPoints
x
y
)
{
m_bNotHVGA
)
{
factorX
CC_CONTENT_SCALE_FACTOR
;
factorY
;
glViewport
GLint
factorX
+
Crayon-h" style="height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(0,
factorY
Crayon-sy" style="height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
w
Crayon-h" style="height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(0,
h
;
}
else
{
Crayon-line
Crayon-striped-line" id="
Crayon-54f2a4f4774dc854808313-42" style="border:0px; padding:0px 5px; margin:0px; height:inherit; background-color:rgb(245,
Crayon-h" style="height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(0,
Crayon-line
Crayon-striped-line" id="
Crayon-54f2a4f4774dc854808313-44" style="border:0px; padding:0px 5px; margin:0px; height:inherit; background-color:rgb(245,
;
}
}
setScissorInPoints
)
{
)
{
;
;
glScissor
Crayon-sy" style="height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(51,
Crayon-line
Crayon-striped-line" id="
Crayon-54f2a4f4774dc854808313-56" style="border:0px; padding:0px 5px; margin:0px; height:inherit; background-color:rgb(245,
Crayon-h" style="height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(0,
;
}
else
{
Crayon-line
Crayon-striped-line" id="
Crayon-54f2a4f4774dc854808313-62" style="border:0px; padding:0px 5px; margin:0px; height:inherit; background-color:rgb(245,
Crayon-h" style="height:inherit; font-size:inherit!important; line-height:inherit!important; color:rgb(0,
Crayon-line
Crayon-striped-line" id="
Crayon-54f2a4f4774dc854808313-64" style="border:0px; padding:0px 5px; margin:0px; height:inherit; background-color:rgb(245,
;
}
/*
增加getScreenScaleFactorX/getScreenScaleFactorY的实现 */
)
{
return
;
}
)
{
;
到此为止,画面上的缩放已经完成啦,但是缩放后触摸的位置还需要修正,继续修改cocos2dx/platform/android/jni/TouchesJni.cpp中关于触摸的缩放,此文件中有多处需要修改的敌方,但是修改方式都一样。以Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesBegin为例
24