Package com.tankz.systems.misc

Source Code of com.tankz.systems.misc.SoundSystem

package com.tankz.systems.misc;

import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;

import com.artemis.Aspect;
import com.artemis.ComponentMapper;
import com.artemis.Entity;
import com.artemis.systems.EntityProcessingSystem;
import com.tankz.components.SoundFile;

public class SoundSystem extends EntityProcessingSystem {
  private ComponentMapper<SoundFile> soundMapper;

  public SoundSystem() {
    super(Aspect.getAspectFor(SoundFile.class));
  }

  @Override
  public void initialize() {
    soundMapper = world.getMapper(SoundFile.class);
  }

  @Override
  protected void process(Entity e) {
    world.deleteEntity(e);
  }

  @Override
  protected void added(Entity e) {
    SoundFile soundFile = soundMapper.get(e);

    try {
      Sound sound = new Sound(soundFile.getSoundFile());
      sound.play(1, 0.3f);
    } catch (SlickException e1) {
      e1.printStackTrace();
    }
  }

}
TOP

Related Classes of com.tankz.systems.misc.SoundSystem

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.