- 注册时间
- 2016-3-14
- 最后登录
- 2016-3-14
- 阅读权限
- 20
- 积分
- 7
- 精华
- 0
- 帖子
- 2
|
发表于 2016-3-14 17:55:30
|显示全部楼层
想要实现图片的根据屏幕大小实现自适应
发现缩放屏幕 图片的缩放不是正常的, 但是在这个分辨率在刷新下 又是正常的? 是bug么, 还是我缩放的过程有错?
bitmapsp是一个sprite 载入了一张640*960d的图片
舞台监听 LGlobal.stage.addEventListener(LEvent.WINDOW_RESIZE,screenAdjust);
function screenAdjust(e){
var rotwidth=Math.round( window.innerWidth);
var rotheight=Math.round( window.innerHeight);
LGlobal.resize(rotwidth,rotheight);
var scalex
var scaley
scalex=rotwidth/640;
scaley=rotheight/960;
var _x=-(rotwidth-640)/2
// number
var scale;
if(scalex<scaley){
scale=scaley;
}else{
scale=scalex;
}
if(bitmapsp){
//bitmapsp.x=_x
bitmapsp.scaleX=bitmapsp.scaleY=scale;
console.log(scale)
}
}
|
|