Package com.sertaogames.cactus2d.components

Examples of com.sertaogames.cactus2d.components.SpriteRendererComponent


    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);
   
    Cactus2DApplication.jukeBox.play(0);
  }
View Full Code Here


 
  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();
View Full Code Here

  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

    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);
View Full Code Here

  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);
View Full Code Here

   
    /** Posiscionamento do game object no meio da tela */
    go.transform.getPosition().set(Gdx.graphics.getWidth()/2-256f*zoomScale,Gdx.graphics.getHeight()/2-128f*zoomScale);
   
    /** Aqui dizemos que ele vai ser desenhado na tela com  a marca */
    SpriteRendererComponent sr = new SpriteRendererComponent(Cactus2DApplication.loadTexture("data/textures/SertaoGames-marca-512x256.png"));
    go.AddComponent(sr);
   
    /** Aqui dizemos que o game object faz parte da GUI */
    sr.gui = true;
   
View Full Code Here

TOP

Related Classes of com.sertaogames.cactus2d.components.SpriteRendererComponent

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.