Class CurrencyGeneratorComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.currency.CurrencyGeneratorComponent

public class CurrencyGeneratorComponent extends Component
Periodically spawns "Scrap Metal" currency at random positions on the screen. The spawn interval, scrap value, texture path and motion parameters are configurable. Actions registered on the Stage are removed in dispose() to avoid leaks.
  • Constructor Details

    • CurrencyGeneratorComponent

      public CurrencyGeneratorComponent(float intervalSec, int scrapValue, String scrapTexturePath, com.badlogic.gdx.math.Vector2 position)
      Creates a new currency generator component with the specified parameters.
      Parameters:
      intervalSec - seconds between spawns
      scrapValue - currency granted per scrap
      scrapTexturePath - texture path for the scrap image
  • Method Details

    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class Component
    • spawnScrapAt

      public void spawnScrapAt()
      Spawns a scrap at the specified coordinates.
    • setScrapSizePx

      public CurrencyGeneratorComponent setScrapSizePx(float px)
      Sets the size of spawned scraps in pixels.
      Parameters:
      px - the size in pixels
      Returns:
      this component for method chaining
    • pause

      public void pause()
      Pauses the sunlight generation
    • resume

      public void resume()
      Resumes the sunlight generation
    • isPaused

      public boolean isPaused()
      Checks if the generator is paused.
      Returns:
      true if the generator is paused, false otherwise
    • dispose

      public void dispose()
      Description copied from class: Component
      Called when the component is disposed. Dispose of any internal resources here.
      Overrides:
      dispose in class Component