Class TouchEventPool


  • public class TouchEventPool
    extends java.lang.Object
    TouchEventPool provides a RingBuffer of jME TouchEvents to help with garbage collection on Android. Each TouchEvent is stored in the RingBuffer and is reused if the TouchEvent has been consumed. If a TouchEvent has not been consumed, it is placed back into the pool at the end for later use. If a TouchEvent has been consumed, it is reused to avoid creating lots of little objects. If the pool is full of unconsumed events, then a new event is created and provided.
    Author:
    iwgeric
    • Constructor Summary

      Constructors 
      Constructor Description
      TouchEventPool​(int maxEvents)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void destroy()  
      com.jme3.input.event.TouchEvent getNextFreeEvent()
      Fetches a touch event from the reuse pool
      void initialize()  
      void storeEvent​(com.jme3.input.event.TouchEvent event)
      Stores the TouchEvent back in the pool for later reuse.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TouchEventPool

        public TouchEventPool​(int maxEvents)
    • Method Detail

      • initialize

        public void initialize()
      • destroy

        public void destroy()
      • getNextFreeEvent

        public com.jme3.input.event.TouchEvent getNextFreeEvent()
        Fetches a touch event from the reuse pool
        Returns:
        a usable TouchEvent
      • storeEvent

        public void storeEvent​(com.jme3.input.event.TouchEvent event)
        Stores the TouchEvent back in the pool for later reuse. It is only reused if the TouchEvent has been consumed.
        Parameters:
        event - TouchEvent to store for later use if consumed.