coocs2d-x 分辨率

config.lua:

CC_DESIGN_RESOLUTION = {
  width = ,
  height = ,
autoscale = "FIXED_HEIGHT",
callback = function(framesize)
local ratio = framesize.width / framesize.height
if ratio <= 1.34 then
-- iPad 768*1024(1536*2048) is 4:3 screen
return {autoscale = "FIXED_WIDTH"}
end
end
}
GameConst.WIN_SIZE = cc.Director:getInstance():getWinSize();

--设计尺寸
GameConst.DESIGN_SIZE = cc.size(, );
function CommonUtils.set_node_EXACT_FIT(node_)

-- 假设:屏幕分辨率(fWidth,fHeight) ; 设计分辨率(dWidth,dHeight)。
-- 放缩因子:k1 = fWidth/dWidth ; k2 = fHeight/dHeight。
-- 则适配后的分辨率大小如下:
-- (1)EXACT_FIT :( dWidth * k1 , dHeight * k2 ) local dSize = cc.size(, );--1280和720是设计尺寸
local winSize = cc.Director:getInstance():getWinSize();
node_:setScale(winSize.width/dSize.width, winSize.height/dSize.height); end

使用:

--适配--wzq

CommonUtils.set_node_EXACT_FIT(self);
self:setPosition((GameConst.WIN_SIZE.width - GameConst.DESIGN_SIZE.width)/, (GameConst.WIN_SIZE.height - GameConst.DESIGN_SIZE.height )/);
上一篇:移动端 FileReader文件上传


下一篇:js 获取指定日期