cc._renderType代表渲染模式:
// Canvas (cc.game.RENDER_TYPE_CANVAS 枚举值为0)
cc._renderType === cc.game.RENDER_TYPE_CANVAS
// WebGL (cc.game.RENDER_TYPE_CANVAS 枚举值为1)
cc._renderType === cc.game.RENDER_TYPE_WEBGL
例如:判断当前模式是否为WEBGL渲染模式
private isWebGL:boolean;
onLoad(){
let type = cc._renderType;
if (type === cc.game.RENDER_TYPE_CANVAS)
{
this.isWebGL = false;
}
else
{
this.isWebGL = true;
}
}
本文介绍如何在Cocos2d-x中判断当前使用的渲染模式是Canvas还是WebGL,通过检查cc._renderType变量并对比cc.game.RENDER_TYPE_CANVAS和cc.game.RENDER_TYPE_WEBGL枚举值。
1826

被折叠的 条评论
为什么被折叠?



