Examples of GameObject


Examples of cc.plural.ecs.engine.GameObject

import cc.plural.graphics.Vertex;

public class TankFactory {

    public static GameObject createTank(Engine engine) {
        GameObject tank = engine.createGameObject();
        tank.setName("Tank");

        GameObject tankBody = engine.createGameObject();
        GeometryComponent geometry = new GeometryComponent();

        //geometry.texture = Texture.createTexture("/images/tank_body_1.png");
//        geometry.model = new Model();
//        VertexData v0 = new VertexData();
//        v0.setXYZ(-0.5f, 0.5f, 0);
//        v0.setRGB(1, 0, 0);
//        v0.setST(0, 0);
//        VertexData v1 = new VertexData();
//        v1.setXYZ(-0.5f, -0.5f, 0);
//        v1.setRGB(0, 1, 0);
//        v1.setST(0, 1);
//        VertexData v2 = new VertexData();
//        v2.setXYZ(0.5f, -0.5f, 0);
//        v2.setRGB(0, 0, 1);
//        v2.setST(1, 1);
//        VertexData v3 = new VertexData();
//        v3.setXYZ(0.5f, 0.5f, 0);
//        v3.setRGB(1, 1, 1);
//        v3.setST(1, 0);
//        geometry.model.verticies = new VertexData[] {v0, v1, v2, v3};
//        geometry.model.indices = new short[] {
//            0, 1, 2,
//            2, 3, 0
//        };
//        geometry.model.load();

        //ShaderProgram shader = new ShaderProgram();
        //shader.createDefaultShaderProgram();
        //geometry.shader = shader;

        tankBody.registerComponent(geometry);
        tankBody.setName("TankBody");

        tank.addChild(tankBody);

//    Component playerComponent = new PlayerDriveComponent();   
//    tank.registerComponent(playerComponent);
View Full Code Here

Examples of com.sertaogames.cactus2d.GameObject

 
  @Override
  public void init() {
    objetos = gameObject.findAll("Objeto");
    timeLabel = gameObject.getComponent(LabelComponent.class);
    GameObject msg = gameObject.find("Message");
    msgLabel = msg.getComponent(LabelComponent.class);
  }
View Full Code Here

Examples of com.sertaogames.cactus2d.GameObject

*/
public class GameObjectsFactory {
 
 
  public static GameObject createObject(int width, int heigth, int j, int i, Vector2 initialPosition){
    GameObject gameObject = new GameObject("Objeto");
   
    Texture tx = Cactus2DApplication.loadTexture("data/textures/allTextures.png", true);
    SpriteRendererComponent sr = SpriteRendererComponent.getTextureRegion(tx,width, heigth, j, i);

    gameObject.AddComponent(sr);

    Utils.offsetCorrection(initialPosition);
    DragAndDropComponent dd = new DragAndDropComponent();
    gameObject.transform.getLocalPosition().set(new Vector2(initialPosition).sub(new Vector2(sr.spriteRegion.getRegionWidth()/2
        ,sr.spriteRegion.getRegionHeight()/2)));
    gameObject.AddComponent(dd);
    gameObject.AddComponent(new AudioComponent("data/sound/drag.wav"));
    gameObject.AddComponent(new MyHomeComponent());
   
    addDinamicPhysicBySprite(gameObject);
    return gameObject;
  }
View Full Code Here

Examples of com.sertaogames.cactus2d.GameObject

   
   
  }
 
  public static GameObject createPhysicsBox() {
    GameObject gameObject = new GameObject("physycsbox");
    float offSetHeight = 1024;
    float offSetWidth = 600;
    int offSetSide = 200;
   
    gameObject.transform.getLocalPosition().sub(offSetSide/2, offSetSide/2);
View Full Code Here

Examples of com.sertaogames.cactus2d.GameObject

   
    return gameObject;
  }

  public static GameObject createBackground() {
    GameObject gameObject = new GameObject("background");
   
    Texture tx = Cactus2DApplication.loadTexture("data/textures/allTextures.png", true);
    SpriteRendererComponent sr = SpriteRendererComponent.getTextureRegion(tx,600, 1024, 0, 0);
    gameObject.AddComponent(sr);
    Utils.offsetCorrection(gameObject.transform.getLocalPosition());
    return gameObject;
  }
View Full Code Here

Examples of com.sertaogames.cactus2d.GameObject

    Utils.offsetCorrection(gameObject.transform.getLocalPosition());
    return gameObject;
  }

  private static void addStaticPolignPhysic(GameObject go, Vector2 dimensions, Vector2 location) {
    GameObject side = new GameObject("side");

    PhysicsComponent p = new PhysicsComponent(1, false, false);
    side.AddComponent(p);
   
    side.transform.getLocalPosition().set(location);
    Vector2 offset = new Vector2(dimensions).mul(0.5f);
    BoxCollider coll = new BoxCollider(dimensions, offset);
    side.AddComponent(coll);
   
    go.addGameObject(side);
  }
View Full Code Here

Examples of com.sertaogames.cactus2d.GameObject

    go.addGameObject(side);
  }


  public static GameObject createController() {
    GameObject controller = new GameObject("Controller");
   
    controller.AddComponent(new GameControllerComponent());
    controller.transform.getLocalPosition().set(10, 600);
    Utils.offsetCorrection(controller.transform.getLocalPosition());
    return controller;
  }
View Full Code Here

Examples of com.sertaogames.cactus2d.GameObject

    Utils.offsetCorrection(controller.transform.getLocalPosition());
    return controller;
  }
 
  public static GameObject createTip(LabelComponent l, GameState newState) {
    GameObject tip = new GameObject("Tip");

    int height = 512;
    int width = 512;
    Texture tx = Cactus2DApplication.loadTexture("data/textures/gui.png", true);
    SpriteRendererComponent sr = SpriteRendererComponent.getTextureRegion(tx ,width, height, 1, 1);
    sr.layer = 2;
    sr.gui = true;
    tip.AddComponent(sr);

    float halfWidth = width * Cactus2DApplication.invCameraZoom / 2;

    tip.transform.getPosition().set(Gdx.graphics.getWidth() / 2 - halfWidth, Gdx.graphics.getHeight() / 2 - height * Cactus2DApplication.invCameraZoom / 2);

    GameObject label = new GameObject("Message");
    label.transform.getPosition().set(halfWidth, 400 * Cactus2DApplication.invCameraZoom);
    tip.addGameObject(label);
   
    GameObject subGameObject = new GameObject("Continue");
    subGameObject.transform.getLocalPosition().add(width * 0.7f* Cactus2DApplication.invCameraZoom, 0);
    subGameObject.AddComponent(new SpriteRendererComponent(null));
    subGameObject.spriteRenderer.gui = true;
    TextureRegion[][] tmp = TextureRegion.split(tx, 128, 128);
    subGameObject.AddComponent(new ButtonComponent(tmp[0][0], tmp[0][1]));
    subGameObject.AddComponent(new AudioComponent("data/sound/click.wav"));
    subGameObject.AddComponent(new NextstateComponent(newState));
    if(GameControllerComponent.state != GameState.WON && GameControllerComponent.state != GameState.LOST){
      tip.addGameObject(subGameObject);
    }
   
    subGameObject = new GameObject("Reload");
    subGameObject.transform.getLocalPosition().add(10, 0);
    subGameObject.AddComponent(new SpriteRendererComponent(null));
    subGameObject.spriteRenderer.gui = true;
    subGameObject.AddComponent(new ButtonComponent(tmp[1][0], tmp[1][1]));
    subGameObject.AddComponent(new AudioComponent("data/sound/click.wav"));
    subGameObject.AddComponent(new LevelLoader(MainLevel.class));
    tip.addGameObject(subGameObject);

    subGameObject = new GameObject("Menu");
    subGameObject.transform.getLocalPosition().add(width * 0.35f * Cactus2DApplication.invCameraZoom, 0);
    subGameObject.AddComponent(new SpriteRendererComponent(null));
    subGameObject.spriteRenderer.gui = true;
    subGameObject.AddComponent(new ButtonComponent(tmp[0][6], tmp[0][7]));
    subGameObject.AddComponent(new AudioComponent("data/sound/click.wav"));
    subGameObject.AddComponent(new LevelLoader(MenuLevel.class));
    tip.addGameObject(subGameObject);
   

    l.alignment = HAlignment.CENTER;
    label.AddComponent(l);
View Full Code Here

Examples of com.sertaogames.cactus2d.GameObject

    return tip;
  }

  public static GameObject createGUI() {
    Texture tx = Cactus2DApplication.loadTexture("data/textures/gui.png", true);
    GameObject gui = new GameObject("Gui");
    int width = 640;
    int height = 128;
    SpriteRendererComponent sprite = SpriteRendererComponent.getTextureRegion(tx, width, height, 3, 0);

    gui.AddComponent(sprite);
    gui.spriteRenderer.gui = true;
    gui.transform.getLocalPosition().sub(20 * Cactus2DApplication.invCameraZoom, 15  * Cactus2DApplication.invCameraZoom);
   
    GameObject subGameObject = new GameObject("Pause");
    height = 128;
    width = 128;
    subGameObject.transform.getLocalPosition().add(465 * Cactus2DApplication.invCameraZoom, 0);
    subGameObject.AddComponent(new SpriteRendererComponent(null));
    TextureRegion[][] tmp = TextureRegion.split(tx, width, height);
    tmp = TextureRegion.split(tx, width, height);
    subGameObject.spriteRenderer.gui = true;
    subGameObject.AddComponent(new ButtonComponent(tmp[0][2], tmp[0][3]));
    subGameObject.AddComponent(new AudioComponent("data/sound/click.wav"));
    subGameObject.AddComponent(new PauseComponent());
    gui.addGameObject(subGameObject);
   
    LabelComponent label = null;
    GameObject time = new GameObject("Time");
    label = new LabelComponent(" ");
    time.transform.getLocalPosition().add(100* Cactus2DApplication.invCameraZoom, 80* Cactus2DApplication.invCameraZoom);
    label.setFontName(TerremotoApplication.fontName);
    time.AddComponent(label);
    time.AddComponent(new SpriteRendererComponent(null));
    time.spriteRenderer.gui = true;
    gui.addGameObject(time);
   
    GameObject points = new GameObject("Points");
    label = new LabelComponent(" ");
    points.transform.getLocalPosition().add(300* Cactus2DApplication.invCameraZoom, 80* Cactus2DApplication.invCameraZoom);
    label.setFontName(TerremotoApplication.fontName);
    points.AddComponent(label);
    points.AddComponent(new SpriteRendererComponent(null));
    points.spriteRenderer.gui = true;
    gui.addGameObject(points);
   
    subGameObject = new GameObject("Clock");
    sprite = SpriteRendererComponent.getTextureRegion(tx, width, height, 6, 3);
    subGameObject.transform.getLocalPosition().add(8* Cactus2DApplication.invCameraZoom, 8* Cactus2DApplication.invCameraZoom);
    subGameObject.AddComponent(sprite);
    subGameObject.spriteRenderer.gui = true;
    gui.addGameObject(subGameObject);
View Full Code Here

Examples of com.sertaogames.cactus2d.GameObject

public class MenuLevel extends Cactus2DLevel {
 
  @Override
  protected void init() {
   
    GameObject go = new GameObject("back");
    Texture texture = Cactus2DApplication.loadTexture("data/textures/allTextures.png", true);
    int width = 600;
    int height = 1024;
    TextureRegion[][] matriz = TextureRegion.split(texture, width, height);
    SpriteRendererComponent sr = new SpriteRendererComponent(texture);
    sr.spriteRegion = matriz[0][0];
    Utils.offsetCorrection(go.transform.getLocalPosition());
   
    go.AddComponent(sr);
    addGameObject(go);
   
    GameObject seismographGO = new GameObject("seismograph");
    texture = Cactus2DApplication.loadTexture("data/textures/gui.png", true);
    width = 512;
    height = 256;
    seismographGO.transform.getPosition().set(300 - width/2, 1024 - height * 1.2f);
    Utils.offsetCorrection(seismographGO.transform.getLocalPosition());
    TextureRegion[][] matriz3 = TextureRegion.split(texture, width, height);
    sr = new SpriteRendererComponent(null,matriz3[2][0]);
    seismographGO.AddComponent(sr);
    addGameObject(seismographGO);
   
    GameObject animatedGO = new GameObject("anim");
    AnimationComponent anim = new AnimationComponent();
    Texture tx  = new Texture(Gdx.files.internal("data/textures/sismoAnim.png"));
    int[] frames = { 0, 1, 2, 3, 4, 5, 6, 7};
    anim.addAnimation("anim", tx, 384, 192, frames, 5, false);
   
    anim.play("anim");
   
    animatedGO.AddComponent(anim);
    animatedGO.AddComponent(new SpriteRendererComponent(null));
    animatedGO.transform.getPosition().add(width/2 - 370/2, height/2 - 215/2);
    seismographGO.addGameObject(animatedGO);
   
    GameObject titleGO = new GameObject("title");
    titleGO.transform.getPosition().add(width/2 - 384/2, height/2 - 128/2);
    width = 384;
    height = 128;
    TextureRegion[][] matriz2 = TextureRegion.split(texture, 384, 128);
     sr = new SpriteRendererComponent(null,matriz2[6][0]);
     titleGO.AddComponent(sr);
    seismographGO.addGameObject(titleGO);
   
    go = new GameObject("play");
    go.AddComponent(new SpriteRendererComponent(null));
   
    Texture bt = Cactus2DApplication.loadTexture("data/textures/gui.png",true);
    width = 256;
    height = 128;
    TextureRegion[][] tmp = TextureRegion.split(bt, width, height);
    go.transform.getLocalPosition().add(Gdx.graphics.getWidth()/2 - 128 * Cactus2DApplication.invCameraZoom, Gdx.graphics.getHeight()/2 - 64 * Cactus2DApplication.invCameraZoom);
    go.spriteRenderer.gui = true;
    go.AddComponent(new ButtonComponent(tmp[2][0],tmp[2][1]));
    go.AddComponent(new LevelLoader(MainLevel.class));
    go.AddComponent(new AudioComponent("data/sound/click.wav"));
    addGameObject(go);

    go = new GameObject("sound");
    tmp = TextureRegion.split(bt, 128, 128);
    go.AddComponent(new ButtonComponent(tmp[1][4],tmp[1][5]));
    go.AddComponent(new SpriteRendererComponent(null));
    go.AddComponent(new ToggleButtonComponent(tmp[1][2],tmp[1][3], tmp[1][4],tmp[1][5]));
    addGameObject(go);
View Full Code Here
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.