浏览代码

- add maxtime for BombControl

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7328 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 14 年之前
父节点
当前提交
650acbc715
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      engine/src/test/jme3test/bullet/BombControl.java

+ 12 - 0
engine/src/test/jme3test/bullet/BombControl.java

@@ -39,7 +39,9 @@ public class BombControl extends RigidBodyControl implements PhysicsCollisionLis
     private float forceFactor = 1;
     private float forceFactor = 1;
     private ParticleEmitter effect;
     private ParticleEmitter effect;
     private float fxTime = 0.5f;
     private float fxTime = 0.5f;
+    private float maxTime = 4f;
     private float curTime = -1.0f;
     private float curTime = -1.0f;
+    private float timer;
 
 
     public BombControl(CollisionShape shape, float mass) {
     public BombControl(CollisionShape shape, float mass) {
         super(shape, mass);
         super(shape, mass);
@@ -133,6 +135,16 @@ public class BombControl extends RigidBodyControl implements PhysicsCollisionLis
     @Override
     @Override
     public void update(float tpf) {
     public void update(float tpf) {
         super.update(tpf);
         super.update(tpf);
+        if(enabled){
+            timer+=tpf;
+            if(timer>maxTime){
+                if(spatial.getParent()!=null){
+                    space.removeCollisionListener(this);
+                    space.remove(this);
+                    spatial.removeFromParent();
+                }
+            }
+        }
         if (enabled && curTime >= 0) {
         if (enabled && curTime >= 0) {
             curTime += tpf;
             curTime += tpf;
             if (curTime > fxTime) {
             if (curTime > fxTime) {