Package com.badlogic.gdx.math

Examples of com.badlogic.gdx.math.Vector2


      System.out.println("X: " + x + " Y: " + y);
  //    System.out.println("Y: " + Gdx.input.getAccelerometerY());
  //    System.out.println("Z: " + Gdx.input.getAccelerometerZ());
  //    System.out.println("R: " + Gdx.input.getRotation());
    }
    if(!touched && g.equals(new Vector2(0,0))){
      g = new Vector2();
      gameObject.world.setGravity(g);
    }
  }
View Full Code Here


    physics.setBodyType(BodyType.KinematicBody);
  }

  @Override
  public void onTouchStay(Vector2 touchPosition) {
    Vector2 pos = screenToWorld(touchPosition.cpy());
    transform.setLocalPosition(pos.sub(spriteRenderer.getHalfSize()));
    checkSnap();
  }
View Full Code Here

 
  private void checkSnap(){
    snapped = false;
    for (Vector2 pos : snapPositions) {
      diff.set(transform.getLocalPosition());
      diff.add(new Vector2(spriteRenderer.spriteRegion.getRegionWidth()/2
          ,spriteRenderer.spriteRegion.getRegionHeight()/2));
      diff.sub(pos);
      if (diff.len2() < 5000) {
        transform.setLocalPosition(new Vector2(pos).sub(new Vector2(spriteRenderer.spriteRegion.getRegionWidth()/2
            ,spriteRenderer.spriteRegion.getRegionHeight()/2)));
        snapped = true;
        break;
      }
    }
View Full Code Here

    renderer = new ShapeRenderer();

    // next we create a SpriteBatch and a font
    batch = new SpriteBatch();

    mLower = new Vector2();
    mUpper = new Vector2();

    // initialize vertices array
    for (int i = 0; i < vertices.length; i++)
      vertices[i] = new Vector2();

    mDrawBodies = drawBodies;
    mDrawJoints = drawJoints;
    mDrawAABBs = drawAABBs;
  }
View Full Code Here

  }

  private void drawSolidPolygon (Vector2[] vertices, int vertexCount, Color color) {
    renderer.setColor(color.r, color.g, color.b, color.a);
    for (int i = 0; i < vertexCount; i++) {
      Vector2 v = vertices[i];
      if (i == 0) {
        lv.set(v);
        f.set(v);
        continue;
      }
View Full Code Here

    Body bodyA = joint.getBodyA();
    Body bodyB = joint.getBodyB();
    Transform xf1 = bodyA.getTransform();
    Transform xf2 = bodyB.getTransform();

    Vector2 x1 = xf1.getPosition();
    Vector2 x2 = xf2.getPosition();
    Vector2 p1 = joint.getAnchorA();
    Vector2 p2 = joint.getAnchorB();

    if (joint.getType() == JointType.DistanceJoint) {
      drawSegment(p1, p2, JOINT_COLOR);
    } else if (joint.getType() == JointType.PulleyJoint) {
      PulleyJoint pulley = (PulleyJoint)joint;
      Vector2 s1 = pulley.getGroundAnchorA();
      Vector2 s2 = pulley.getGroundAnchorB();
      drawSegment(s1, p1, JOINT_COLOR);
      drawSegment(s2, p2, JOINT_COLOR);
      drawSegment(s1, s2, JOINT_COLOR);
    } else if (joint.getType() == JointType.MouseJoint) {
      drawSegment(joint.getAnchorA(), joint.getAnchorB(), JOINT_COLOR);
View Full Code Here

  }

  private void drawContact (Contact contact) {
    WorldManifold worldManifold = contact.getWorldManifold();
    if (worldManifold.getNumberOfContactPoints() == 0) return;
    Vector2 point = worldManifold.getPoints()[0];
    renderer.point(point.x, point.y, 0);
  }
View Full Code Here

    Vector3 orig = new Vector3(0, 0, 0);
    Vector3 vec = new Vector3(1, 0, 0);
    project(orig);
    project(vec);
    Vector2 d = new Vector2(vec.x - orig.x, -(vec.y - orig.y));
    return d.angle();
  }
View Full Code Here

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

  private static void addDinamicPhysicBySprite(GameObject gameObject) {
   
    PhysicsComponent p = new PhysicsComponent(1, BodyType.KinematicBody, false);
    gameObject.AddComponent(p);

    Vector2 offset = new Vector2(
        gameObject.spriteRenderer.spriteRegion.getRegionWidth()/2,
        gameObject.spriteRenderer.spriteRegion.getRegionHeight()/2);
   
    BoxCollider coll = new BoxCollider(
        new Vector2(gameObject.spriteRenderer.spriteRegion.getRegionWidth()/2, gameObject.spriteRenderer.spriteRegion.getRegionHeight()/2)
        , offset);
   
    gameObject.AddComponent(coll)
   
   
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.math.Vector2

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.