Class Item

  • All Implemented Interfaces:
    Drawable, com.badlogic.gdx.utils.Disposable
    Direct Known Subclasses:
    Interactable

    class Item
    extends java.lang.Object
    implements Drawable
    An Item denotes a drawable non-Character object.
    Author:
    ENG1 Team 23 (Cohort 3)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.badlogic.gdx.physics.box2d.Body body
      The collision and interaction Body zone of the Item
      private float height
      The height of the Item, in in-game metres
      private com.badlogic.gdx.graphics.Texture texture
      The LibGDX Drawable graphical representation of the Sprite
      private float width
      The width of the Item, in in-game metres
    • Constructor Summary

      Constructors 
      Constructor Description
      Item​(com.badlogic.gdx.math.Vector2 position, com.badlogic.gdx.graphics.Texture texture, Area area, float width, float height)
      Instantiates a new Item with the given initial parameters
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()
      Releases all resources used by the Item
      (package private) com.badlogic.gdx.math.Vector2 getPosition()
      Retrieves the position of the Item
      void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
      Registers the current Item onto the given game instance SpriteBatch
      • Methods inherited from class java.lang.Object

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

      • texture

        private final com.badlogic.gdx.graphics.Texture texture
        The LibGDX Drawable graphical representation of the Sprite
      • width

        private final float width
        The width of the Item, in in-game metres
      • height

        private final float height
        The height of the Item, in in-game metres
      • body

        private final com.badlogic.gdx.physics.box2d.Body body
        The collision and interaction Body zone of the Item
        See Also:
        World
    • Constructor Detail

      • Item

        Item​(com.badlogic.gdx.math.Vector2 position,
             com.badlogic.gdx.graphics.Texture texture,
             Area area,
             float width,
             float height)
        Instantiates a new Item with the given initial parameters
        Parameters:
        position - The initial position of the Item, specified as in-game metre components
        texture - The initial Sprite Texture
        area - The Area into which the Item should be drawn
        width - The initial width, in in-game metres
        height - The initial height, in in-game metres
    • Method Detail

      • dispose

        public void dispose()
        Releases all resources used by the Item
        Specified by:
        dispose in interface com.badlogic.gdx.utils.Disposable
      • render

        public void render​(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
        Registers the current Item onto the given game instance SpriteBatch
        Specified by:
        render in interface Drawable
        Parameters:
        batch - The SpriteBatch to which the Item should be polled
      • getPosition

        com.badlogic.gdx.math.Vector2 getPosition()
        Retrieves the position of the Item
        Returns:
        The position of the body