Package com.sertaogames.terremoto.component

Source Code of com.sertaogames.terremoto.component.TipComponent

package com.sertaogames.terremoto.component;

import com.badlogic.gdx.audio.Sound;
import com.sertaogames.cactus2d.Cactus2DApplication;
import com.sertaogames.cactus2d.Component;
import com.sertaogames.cactus2d.GameObject;
import com.sertaogames.cactus2d.components.LabelComponent;
import com.sertaogames.terremoto.GameState;
import com.sertaogames.terremoto.TerremotoApplication;
import com.sertaogames.terremoto.factory.GameObjectsFactory;

public class TipComponent extends Component {
  public static LabelComponent messageLabel = null;
  private boolean active = false;
  private GameObject tip = null;
  String message = null;
  GameState nextState = null;
  public static Sound sound = Cactus2DApplication.loadSound("data/sound/msg.wav");;
 
  @Override
  public void init() {
    sound.play();
    createTip();
  }

  private void createTip() {
    messageLabel = new LabelComponent(message);
    messageLabel.setFontName(TerremotoApplication.fontName);
    tip = GameObjectsFactory.createTip(messageLabel, nextState);
    GameControllerComponent.tipGameObject = tip;
    gameObject.parent.addGameObject(tip);
  }

  public TipComponent(boolean active, String message, GameState nextState) {
    this.active = active;
    this.message = message;
    this.nextState = nextState;
  }

  public void setMessage(String message) {
    this.message = message;
  }
 
  @Override
  public void update() {
    if(active){
      messageLabel.text = message;
      tip.setActive(true);
    } else {
      tip.setActive(false);
    }
  }
 
  @Override
  public void onClick() {
    createTip();
  }
}
TOP

Related Classes of com.sertaogames.terremoto.component.TipComponent

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.