📄 cplayerbomb.java
字号:
/*
* CPlayerBoom.java
*
* Created on 2006年4月16日, 下午13:40
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package gamepacket;
import java.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
/**
*
* @author ztt
*/
public class CPlayerBomb
{
private int dx,dy;//炸弹坐标
private int Speed;//炸弹移动速度
private int width,height;//屏幕大小
//炸弹精灵图
public Sprite spt_playerbomb;
private boolean IsShow;//是否显示炸弹
public CPlayerBomb (int scrWidth,int scrHeight,LayerManager lm)
{
Speed=1;//初始速度1
IsShow=false;
width=scrWidth;
height=scrHeight;
try
{
spt_playerbomb=new Sprite(Image.createImage("/img/playerbomb.png"));
} catch (IOException ex){}
lm.append (spt_playerbomb);
spt_playerbomb.setVisible (false);//隐藏炸弹
}
public void SetPoint(int x,int y)
{
dx=x;
dy=y;
}
public void Move()
{
if(IsShow==true)
{dy+=Speed;//向下移动
spt_playerbomb.setVisible (true);
spt_playerbomb.setPosition (this.dx,this.dy);
}
if(dy>height)
{
IsShow=false;
spt_playerbomb.setVisible (false);//炸弹不可见
}
}
public void SetShow(boolean show)
{
IsShow=show;
}
public boolean GetShow()
{
return IsShow;
}
public boolean IsOver(CCpuShip cpuship)
{
//碰撞检测
if(spt_playerbomb.collidesWith (cpuship.spt_cpuship,true))
{
spt_playerbomb.setVisible (false);//炸弹图片不可见
this.IsShow=false;//炸弹不可见
return true;
}
else
{
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -