?? class_camera.java
字號(hào):
public class Class_Camera
{
//目標(biāo)位置
static short x0,y0;
//當(dāng)前位置
static short x,y;
//拍攝范圍
static short width=176,height=208;
public Class_Camera()
{
}
//處理屏幕跟隨坦克的方法
public static void setFollow(Class_Tank ct)
{
if(ct.getRefPixelX()<width/2)
x0=0;
else if(ct.getRefPixelX()>Class_Map.width-width/2)
x0=(short) (Class_Map.width-width);
else
x0=(short) (ct.getRefPixelX()-width/2);
if(ct.getRefPixelY()<height/2)
y0=0;
else if(ct.getRefPixelY()>Class_Map.height-height/2)
y0=(short) (Class_Map.height-height);
else
y0=(short) (ct.getRefPixelY()-height/2);
}
//處理屏幕跟隨子彈的方法
public static void setFollow(Class_Bullet cb)
{
if(cb.getRefPixelX()<width/2)
x0=0;
else if(cb.getRefPixelX()>Class_Map.width-width/2)
x0=(short) (Class_Map.width-width);
else
x0=(short) (cb.getRefPixelX()-width/2);
if(cb.getRefPixelY()<=y0+height/4)
{
if(cb.getRefPixelY()<=height/4)
y0=0;
else
y0=(short) (cb.getRefPixelY()-height/4);
}
if(cb.getRefPixelY()>=y0+3*height/4)
{
if(cb.getRefPixelY()>=Class_Map.height-height/4)
y0=(short) (Class_Map.height-height);
else
y0=(short) (cb.getRefPixelY()-3*height/4);
}
}
//判斷對(duì)象是否處于屏幕中的方法
public static boolean isShow(Class_GameObject go)
{
if(go.getX()>=x-go.getWidth()&&go.getX()<=x+width&&go.getY()>=y-go.getHeight()&&go.getY()<=y+height)
return true;
else return false;
}
//重置攝象機(jī)的方法
public static void rePut()
{
if(x>x0)
{
x-=10;
if(x<x0+10)
x=x0;
}else if(x<x0)
{
x+=10;
if(x>x0-10)
x=x0;
}
if(y>y0)
{
y-=10;
if(y<y0+10)
y=y0;
}else if(y<y0)
{
y+=10;
if(y>y0-10)
y=y0;
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -