Package framework.component

Examples of framework.component.ParentComponent$ChildRemovedEvent


import framework.rendering.TextRenderComponent;
import framework.spacial.PositionComponent;

public class TurnCounterGenerator {
  public static void setUpTurnCounter() {
    ParentComponent counterParent = new ParentComponent();
    counterParent.addComponent(new TurnCounterComponent());
    counterParent.addComponent(new TextRenderComponent("Current Move:"));
   
    SpriteComponent spriteComp = new SpriteComponent(ColourManager.getSquareForPlayer(0),new Vector2f(125, -8), 40, 40);
    //spriteComp.setAlwaysOnTop();
    counterParent.addComponent(spriteComp);
    //300 500
    counterParent.addComponent(new PositionComponent(20, 28));
   
    ComponentSystem.getInstance().getParentComponentByLabel("Background").addComponent(counterParent);
  }
View Full Code Here


  public static void setUpCursor(){
    ComponentSystem.getInstance().getRoot().addComponent(generateCursor());
  }

  private static ParentComponent generateCursor(){
    ParentComponent cursorParent = new ParentComponent("Cursor");

    SpriteComponent spriteComp = new SpriteComponent(ColourManager.getCursorForPlayer(0), new Vector2f(-10, -10), 20, 20);
    spriteComp.setAlwaysOnTop();
    cursorParent.addComponent(spriteComp);
   
    CollisionComponent collis = new CollisionComponent(new CircularCollisionMask(10));
    cursorParent.addComponent(collis);

    setUpEventListener(collis);

    cursorParent.addComponent(new PositionComponent(50,50));
    cursorParent.addComponent(new MouseFollowerComponent());
    return cursorParent;
  }
View Full Code Here

import framework.userinput.MouseListenerSystem.MousePressedEvent;

public abstract class TestsGen {
  public static void test1(){
    ComponentSystem cs = ComponentSystem.getInstance();
    ParentComponent root = cs.getRoot();
   
    final ParentComponent p1 = new ParentComponent();
    p1.addComponent(new PositionComponent(100,100));
    SpriteComponent s1 = new SpriteComponent("res/img/square.png", new Vector2f(-25, -25), 50, 50);
    s1.setAlwaysOnTop();
    p1.addComponent(s1);
   
    p1.addComponent(new MouseFollowerComponent());
    p1.addComponent(new CollisionComponent(new CircularCollisionMask(25)));
    p1.addComponent(new OrientationComponent(-100));
    final SpinComponent spin = new SpinComponent(0.1f);
    //p1.addComponent(spin);
    EventSystem.getInstance().registerEventListener(new EventListener() {
      private int button;
      @Override
      public void onEvent(Event e) {
        int b = ((MousePressedEvent) e).getButton();
        if(b != button){
          spin.setValue(-spin.getValue());
          button = b;
        }
        p1.addComponent(spin);
      }
     
      @Override
      public int getUniqueID() {
        return 0;
      }
     
      @Override
      public String getType() {
        return "Custom";
      }
    }, "MousePressed", null);
   
    EventSystem.getInstance().registerEventListener(new EventListener() {
      @Override
      public void onEvent(Event e) {
        p1.removeComponent(spin);
      }
     
      @Override
      public int getUniqueID() {
        return 1;
      }
     
      @Override
      public String getType() {
        return "Custom";
      }
    }, "MouseReleased", null);
   
    ParentComponent gridParent = SquaresGen.generateGrid(90, 50, 10, 10, 50);
    root.addComponent(gridParent);
    gridParent.addComponent(new OrbitalVelocityComponent(0.5f, new Vector2f(95, 55)));
   
   
   
    ParentComponent p2 = new ParentComponent();
   
    p1.addComponent(p2);
   
    p2.addComponent(new PositionComponent(10, 150));
    p2.addComponent(new SpriteComponent("res/img/square.png"));
    p2.addComponent(new OrientationComponent(100));
    p2.addComponent(new TextRenderComponent("Click to rotate!"));
   
    ParentComponent p3 = new ParentComponent();
    p3.addComponent(new PositionComponent (700,100));
    p3.addComponent(new SpriteComponent("res/img/line.png",new Vector2f(0, 0), 50, 50));
    p3.addComponent(new OrientationComponent(100));
   
   
    root.addComponent(p1);
    root.addComponent(p3);
    root.addComponent(new ColourChangeComponent());
View Full Code Here

    GameLoader.loadGameWithOptionsMenu(6, 6, gc);
  }
 
  private void initTimer(){
    ComponentSystem cs = ComponentSystem.getInstance();
    ParentComponent root = cs.getRoot();
    clock = new SystemClockComponent();
    root.addComponent(clock);
  }
View Full Code Here

    root.addComponent(p3);
    root.addComponent(new ColourChangeComponent());
  }
 
  public static void test2(){
    ParentComponent root = ComponentSystem.getInstance().getRoot();
    ParentComponent gridLine = new ParentComponent();
    root.addComponent(gridLine);
    gridLine.addComponent(new GridLine());
    gridLine.addComponent(new SpriteComponent("res/img/square.png", 10, 50));
    gridLine.addComponent(new PositionComponent(500,500));
    gridLine.addComponent(new OrientationComponent(100));
    gridLine.addComponent(new CollisionComponent(new LineCollisionMask(new Line(0, 0, 0, 100))));
    //gridLine.addComponent(new CollisionComponent(new RectangularCollisionMask(new Rectangle(10, 50))));
   
    ParentComponent cursor = new ParentComponent();
    root.addComponent(cursor);
    cursor.addComponent(new MouseFollowerComponent());
    cursor.addComponent(new PositionComponent(0,0));
    cursor.addComponent(new SpriteComponent("res/img/dot.png",new Vector2f(-5,-5),10,10));
    //cursor.addComponent(new CollisionComponent(new PointCollisionMask()));
    cursor.addComponent(new CollisionComponent(new CircularCollisionMask(5)));
    //cursor.addComponent(new CollisionComponent(new RectangularCollisionMask(new Rectangle(10, 10), new Vector2f(-5, -5))));
  }
View Full Code Here

  private static void loadGridGraphics(Grid grid){
    //The order of the code here is important. Do not change, or dots and lines will not be positioned correctly.
    //TODO Make the order unimportant here.
   
    ParentComponent gridParent = new ParentComponent();
    ComponentSystem.getInstance().getRoot().addComponent(gridParent);
   
    //Create the graphics for the dots, lines, and squares.
    int topLeftX = 196;
    int topLeftY = 105;
    int spacing = 75;
   
    GridLineGenerator.generateLineGrid(grid, gridParent, spacing);
    SquareGenerator.generateSquares(grid, gridParent, spacing);
   
    PositionComponent pos = new PositionComponent(0, 0);
    gridParent.addComponent(pos);
    pos.addVector(new Vector2f(topLeftX, topLeftY));
   
    DotsGenerator.createDots(topLeftX, topLeftY , grid.getDotsWidth() , grid.getDotsHeight() , spacing, gridParent);
  }
View Full Code Here

import framework.spacial.PositionComponent;

public class SquaresGen {

  public static ParentComponent generateGrid(int x, int y, int width, int height, float gridSpacing){
    ParentComponent p = new ParentComponent();
    PositionComponent pos = new PositionComponent(x,y);
    p.addComponent(pos);
    p.addComponent(new Grid(width, height, gridSpacing));
    return p;
  }
View Full Code Here

    p.addComponent(new Grid(width, height, gridSpacing));
    return p;
  }
 
  public static ParentComponent generateDot(ParentComponent grandparent, int gridX, int gridY, float gridSpacing){
    ParentComponent p = new ParentComponent();
    grandparent.addComponent(p);
    PositionComponent pos = new PositionComponent(0,0);
    p.addComponent(pos);
    pos.setRelativeToParent(new Vector2f(gridSpacing*gridX,gridSpacing*gridY));
    p.addComponent(new Dot(gridX, gridY));
    p.addComponent(new SpriteComponent("res/img/dot.png",new Vector2f(-10, -10), 20, 20));
    p.addComponent(new CollisionComponent(new CircularCollisionMask(10)));
    return p;
  }
View Full Code Here

    super.onAddedToParent(parent);
    if(parent != null){
      for(int i = 0; i < width; i++){
        dots.add(new ArrayList<Dot>());
        for(int j = 0; j < height; j++){
          ParentComponent p = SquaresGen.generateDot(getParent(), i, j, gridSpacing);
          dots.get(i).add((Dot)p.getChildByType(Dot.class.getName()));
        }
      }
    }
  }
View Full Code Here

      for(int i = 0;fromComponent != null && i < stepsUpTree; i++){
        fromComponent = fromComponent.getParent();
      }
      if(fromComponent != null){
        if(branchesDownTree.length > 0){
          ParentComponent p = ((ParentComponent) fromComponent);
          for(int i = 1; i < branchesDownTree.length-1; i++){
            p =  ((ParentComponent) fromComponent);
            fromComponent = p.getComponent("ParentComponent", branchesDownTree[i]);
          }
          fromComponent = p.getComponent(getType(), branchesDownTree[branchesDownTree.length - 1]);
        }
      }
    }
    return fromComponent;
  }
View Full Code Here

TOP

Related Classes of framework.component.ParentComponent$ChildRemovedEvent

Copyright © 2018 www.massapicom. 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.