Fork me on GitHub

整数结果整体偏移1方法--取整计算原值一半

GUI.DrawTexture(new Rect((Screen.width - Imagetexture.width) >>1, 10, 120, 120), Imagetexture);

 

假设(Screen.width - Imagetexture.width)是300    二进制为 100101100    

向右移动一位    为    10010110   计算之后   正好是150    是原来一半   

 

结果不用判断奇偶,如果(Screen.width - Imagetexture.width)为奇数,则结果  为减1除以2

posted on 2012-06-07 15:47  pengyingh  阅读(200)  评论(0)    收藏  举报

导航