📄 bulletplantlistener.java
字号:
import com.threed.jpct.*;
/**
* A CollisionListener that will be notified when a bullet hits a plant. This
* listener will be added to every plant.
*/
public class BulletPlantListener implements CollisionListener {
public boolean requiresPolygonIDs() {
// not needed in this case...
return false;
}
public void collision(CollisionEvent e) {
if (e.getType()==CollisionEvent.TYPE_TARGET && e.getSource()!=null) {
if (e.getSource() instanceof Bullet) {
// The collision has really been caused by a bullet!
Bullet bullet=(Bullet) e.getSource();
Plant plant=(Plant) e.getObject();
plant.destroy();
bullet.disable();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -