Package model_pkg.gameobject_pkg

Source Code of model_pkg.gameobject_pkg.BalloonFactory

package model_pkg.gameobject_pkg;

import def_classes.Box;
import def_classes.Point;
import display_pkg.SpriteSheet;

/**
* Factory class for creating Balloons.
* For usage directions, see <i>GameObjectFactory</i>.
* @author Johansson M.
*/
public class BalloonFactory extends GameObjectFactory {

  private static SpriteSheet  spriteSheet;           // The sprite sheet
  private static Point     templateStartPosition;  // The start position
  private static Box       templateBoundingBox;    // The bounding-box
 
  private static BalloonFactory me;
 
  private BalloonFactory() {
    templateBoundingBox = new Box(1, 1, 51, 64);
  }
 
  public static BalloonFactory getFactory() {
    if (me == null) {
      me = new BalloonFactory();
    }
    return me;
  }
 
  public static void setTemplateSpriteSheet(SpriteSheet sheet) {
    spriteSheet = sheet;
  }
 
  public static void setTemplatePosition(Point pos) {
    templateStartPosition = pos;
  }
 
  public Balloon instantiate() {
    System.out.println(templateStartPosition.getIntX() + ", " + templateStartPosition.getIntY());
    Balloon balloon = new Balloon(
        templateStartPosition.getIntX(),
        templateStartPosition.getIntY(),
        templateBoundingBox,
        spriteSheet);
    return balloon;
  }
}
TOP

Related Classes of model_pkg.gameobject_pkg.BalloonFactory

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.