--on prepareMovie me
--myStageRect=the deskTopRectList[1]
--(the stage).rect=myStageRect
--(the stage).drawRect=mystageRect
--end
下面这段代码实现的功能是:
1、舞台居中
2、根据屏幕宽高比和舞台宽高比实现电影的不变形缩放(即,如果舞台宽高比小,则上下充满,左右留空;如果屏幕宽高比小,则左右充满,上下留空;)
on prepareMovie
screenRect = _system.deskTopRectList[1]
wPreH = (screenRect.right-screenRect.left)*1.0/(screenRect.bottom -screenRect.top)
movieRect = _movie.stage.rect
wPreW = (movieRect.right-movieRect.left)*1.0/(screenRect.right-screenRect.left)
hPreH = (movieRect.bottom - movieRect.top)*1.0/(screenRect.bottom -screenRect.top)
if wPreW >= hPreH then
diffH = screenRect.height - movieRect.height/wPreW
newDrawRect = rect(0, 0, screenRect.width, screenRect.height - diffH)
newMovieRect = rect(screenRect.left, screenRect.top + diffH/2, screenRect.right,screenRect.bottom - diffH/2)
else
diffW = screenRect.width - movieRect.width/hPreH
newDrawRect = rect(0, 0, screenRect.width - diffW, screenRect.height)
newMovieRect = rect(screenRect.left + diffW/2, screenRect.top, screenRect.right- diffW/2, screenRect.bottom)
end if
_movie.stage.rect = newMovieRect
_movie.stage.drawRect = newDrawRect
end
根据这个修改,是可以只实现居中,不放缩的
这个代码放在电影脚本中,并保证没有其他的prepareMovie处理子,不用修改直接使用
别外:
可以在全屏的第一帧写
on exitframe me
sprite(1).left=***
sprite(1).top=***
sprite(1).width=***
sprite(1).height=***
end
|