Class AbstractBehavior

java.lang.Object
com.xebisco.yield.AbstractBehavior
All Implemented Interfaces:
Behavior, Closeable, AutoCloseable
Direct Known Subclasses:
Application, ComponentBehavior, Entity2DContainer, SystemBehavior

public abstract class AbstractBehavior extends Object implements Behavior
Provides an abstract implementation of the Behavior interface, tracking the number of frames since its activation and defining the lifecycle of a behavior.
  • Constructor Details

    • AbstractBehavior

      public AbstractBehavior()
  • Method Details

    • tick

      public void tick(ContextTime time)
      Updates the behavior each frame. It calls onStart() on the first frame, then calls onUpdate(ContextTime) on every frame including the first.
      Parameters:
      time - The context time for the current frame, providing timing information.
    • frames

      public long frames()
      Returns the number of frames since the behavior started.
      Returns:
      The number of frames since the behavior was activated.