Package com.l2client.model.jme

Source Code of com.l2client.model.jme.MessagesBillboardControl

package com.l2client.model.jme;

import com.jme3.math.Vector3f;
import com.jme3.scene.control.BillboardControl;

public class MessagesBillboardControl extends BillboardControl {
 
  private float ttl = 1f;
  private float speed = 1f;
  private float lived = 0f;
 
  public MessagesBillboardControl(){}
 
  public MessagesBillboardControl(float timeToLive, float unitsPerSecond){
    super();
    ttl = timeToLive;
    speed = unitsPerSecond;
  }
 
  public void setTravelSpeed(float unitsPerSecond){
    speed = unitsPerSecond;
  }
 
  public void setTimeToLive(float timeToLive){
    ttl = timeToLive;
  }

    @Override
    protected void controlUpdate(float tpf) {
      lived += tpf;
      if(lived > ttl){
        //remove
        if(spatial != null){
          spatial.removeFromParent();
          spatial.removeControl(this);
          spatial = null;
        }
      } else {
        //update position
        if(spatial != null){
          Vector3f v = spatial.getLocalTranslation();
          v.y+= speed*tpf;
          spatial.setLocalTranslation(v.x, v.y, v.z);
        }
      }
    }
}
TOP

Related Classes of com.l2client.model.jme.MessagesBillboardControl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.