Package com.sprites

Class SimpleSprite

    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleSprite​(com.badlogic.gdx.graphics.Texture spriteTexture)
      Constructor that creates a sprite at a given position using a given texture..
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void decreaseInternalTime()
      Decrement or reset the internal time of the sprite used for timing of attacks
      void dispose()
      Dispose of assets used by the class.
      void drawDebug​(com.badlogic.gdx.graphics.glutils.ShapeRenderer renderer)
      Enables drawing of the hitbox to it can be seen.
      com.badlogic.gdx.math.Vector2 getCentre()  
      float getCentreX()
      Get the value of the centre x-coordinate of the sprite.
      float getCentreY()
      Get the value of the centre y-coordinate of the sprite.
      com.badlogic.gdx.math.Polygon getDamageHitBox()
      Get the damage hit box of the sprite.
      ResourceBar getHealthBar()
      Get the health bar of the sprite.
      float getHeight()
      Get the current height of the sprite.
      float getInternalTime()
      Get the internal time of the sprite.
      com.badlogic.gdx.math.Polygon getMovementHitBox()
      Get the movement hit box of the sprite.
      float getWidth()
      Get the current width of the sprite.
      void removeSprite​(com.badlogic.gdx.graphics.Texture destroyedTexture)
      Enables drawing of the hitbox to it can be seen.
      void resetRotation​(float degrees)
      Resets the rotation of the sprite, but also the hit boxes
      void rotate​(float degrees)
      Overrides Sprite class method to rotate the sprite and hitbox at once.
      void setInternalTime​(int time)
      Set the internal time of the sprite.
      void setMovementHitBox​(float rotation)
      Changes the movement hit box to a triangle for better movement and collisions
      void setSize​(float width, float height)
      Overrides Sprite class method to keep seperate values for width and height.
      void update​(com.badlogic.gdx.graphics.g2d.Batch batch)
      Update the sprite position, hitbox and health bar.
      • Methods inherited from class com.badlogic.gdx.graphics.g2d.Sprite

        draw, draw, flip, getBoundingRectangle, getColor, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, getX, getY, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setFlip, setOrigin, setOriginBasedPosition, setOriginCenter, setPackedColor, setPosition, setRegion, setRotation, setScale, setScale, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateY
      • Methods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion

        getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, split
      • Methods inherited from class java.lang.Object

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

      • SimpleSprite

        public SimpleSprite​(com.badlogic.gdx.graphics.Texture spriteTexture)
        Constructor that creates a sprite at a given position using a given texture.. Creates a sprite at (0,0) using a given texture.
        Parameters:
        spriteTexture - The texture the sprite should use.
    • Method Detail

      • update

        public void update​(com.badlogic.gdx.graphics.g2d.Batch batch)
        Update the sprite position, hitbox and health bar. Must be called every frame in order to draw the sprite.
        Parameters:
        batch - The batch to draw onto.
      • decreaseInternalTime

        public void decreaseInternalTime()
        Decrement or reset the internal time of the sprite used for timing of attacks
      • drawDebug

        public void drawDebug​(com.badlogic.gdx.graphics.glutils.ShapeRenderer renderer)
        Enables drawing of the hitbox to it can be seen.
        Parameters:
        renderer - The shape renderer to draw onto.
      • removeSprite

        public void removeSprite​(com.badlogic.gdx.graphics.Texture destroyedTexture)
        Enables drawing of the hitbox to it can be seen.
        Parameters:
        destroyedTexture - The flooded texture to replace the sprite with
      • setSize

        public void setSize​(float width,
                            float height)
        Overrides Sprite class method to keep seperate values for width and height. Also updates the sprites width and height and creates a new hitbox and health bar.
        Overrides:
        setSize in class com.badlogic.gdx.graphics.g2d.Sprite
        Parameters:
        width - The width the sprite should be set to.
        height - The height the sprite should be set to.
      • setMovementHitBox

        public void setMovementHitBox​(float rotation)
        Changes the movement hit box to a triangle for better movement and collisions
        Parameters:
        rotation - amount in degrees to rotate the hitbox by
      • rotate

        public void rotate​(float degrees)
        Overrides Sprite class method to rotate the sprite and hitbox at once.
        Overrides:
        rotate in class com.badlogic.gdx.graphics.g2d.Sprite
        Parameters:
        degrees - The degree to rotate to.
      • resetRotation

        public void resetRotation​(float degrees)
        Resets the rotation of the sprite, but also the hit boxes
        Parameters:
        degrees - what the starting rotation should be
      • getHealthBar

        public ResourceBar getHealthBar()
        Get the health bar of the sprite.
        Returns:
        The health bar of the sprite.
      • getInternalTime

        public float getInternalTime()
        Get the internal time of the sprite.
        Returns:
        The internal time of the sprite.
      • setInternalTime

        public void setInternalTime​(int time)
        Set the internal time of the sprite.
        Parameters:
        time - new internal time
      • getMovementHitBox

        public com.badlogic.gdx.math.Polygon getMovementHitBox()
        Get the movement hit box of the sprite.
        Returns:
        The hit box of the sprite.
      • getDamageHitBox

        public com.badlogic.gdx.math.Polygon getDamageHitBox()
        Get the damage hit box of the sprite.
        Returns:
        The hit box of the sprite.
      • getWidth

        public float getWidth()
        Get the current width of the sprite.
        Overrides:
        getWidth in class com.badlogic.gdx.graphics.g2d.Sprite
        Returns:
        The width of the sprite.
      • getHeight

        public float getHeight()
        Get the current height of the sprite.
        Overrides:
        getHeight in class com.badlogic.gdx.graphics.g2d.Sprite
        Returns:
        The height of the sprite.
      • getCentreX

        public float getCentreX()
        Get the value of the centre x-coordinate of the sprite.
        Returns:
        The cente X-coordinate of the sprite.
      • getCentreY

        public float getCentreY()
        Get the value of the centre y-coordinate of the sprite.
        Returns:
        The centre y-coordinate of the sprite.
      • getCentre

        public com.badlogic.gdx.math.Vector2 getCentre()
      • dispose

        public void dispose()
        Dispose of assets used by the class.