if(SCREEN_WIDTH < SCREEN_HEIGHT){
temp_x = (int)(PRE_SCREEN_WIDTH * ratio);
temp_y = (int)(PRE_SCREEN_HEIGHT * ratio);
}else{
temp_x = (int)(PRE_SCREEN_HEIGHT * ratio);
temp_y = (int)(PRE_SCREEN_WIDTH * ratio);
}
//填充多余的空间
if(x == y){
}if(x > 0){
MyRectColor mrcBorder1 = Box2dUtil.createBox(x/2, temp_y/2,
x/2,temp_y/2,
true,world,
0f,0f,0f,
temp_c, -100);
al.add(mrcBorder1);
MyRectColor mrcBorder2 = Box2dUtil.createBox(x/2 + temp_x + x, temp_y/2,
x/2,temp_y/2,
true,world,
0f,0f,0f,
temp_c, -100);
al.add(mrcBorder2);
}else if(y > 0){
MyRectColor mrcBorder1 = Box2dUtil.createBox(x + temp_x/2, y/2,
temp_x/2,y/2,
true,world,
0f,0f,0f,
temp_c, -100);
al.add(mrcBorder1);
MyRectColor mrcBorder2 = Box2dUtil.createBox(x + temp_x/2, y + temp_y + y/2,
temp_x/2,y/2,
true,world,
0f,0f,0f,
temp_c, -100);
al.add(mrcBorder2);
}
//四个边框
//左
MyRectColor mrcleft=Box2dUtil.createBox( x + kd/2*ratio, y + temp_y/2, kd/2*ratio, temp_y/2,
true,world,0,0, 0,Color.RED, -5);
al.add(mrcleft);
//右
MyRectColor mrcright=Box2dUtil.createBox(x + temp_x - kd/2*ratio, y + temp_y/2, kd/2*ratio, temp_y/2,
true,world,0,0, 0,Color.RED, -5);
al.add(mrcright);
//上
MyRectColor mrcup=Box2dUtil.createBox(x + temp_x/2, y + kd/2*ratio, y + temp_x/2, kd/2*ratio,
true,world,0,0, 0,Color.RED, -5);
al.add(mrcup);
//下
MyRectColor mrclow=Box2dUtil.createBox(x + temp_x/2, y + temp_y-kd/2*ratio, temp_x/2, kd/2*ratio,
true,world,0,0, 0,Color.RED, -5);
al.add(mrclow);
android box2d 设置边框,填充边缘;
猜你喜欢
转载自blog.csdn.net/julicliy/article/details/81703770
今日推荐
周排行