use of com.badlogic.gdx.math.Vector2 in project libgdx by libgdx.
the class Group method hit.
public Actor hit(float x, float y, boolean touchable) {
if (touchable && getTouchable() == Touchable.disabled)
return null;
Vector2 point = tmp;
Actor[] childrenArray = children.items;
for (int i = children.size - 1; i >= 0; i--) {
Actor child = childrenArray[i];
if (!child.isVisible())
continue;
child.parentToLocalCoordinates(point.set(x, y));
Actor hit = child.hit(point.x, point.y, touchable);
if (hit != null)
return hit;
}
return super.hit(x, y, touchable);
}
use of com.badlogic.gdx.math.Vector2 in project libgdx by libgdx.
the class Image method layout.
public void layout() {
if (drawable == null)
return;
float regionWidth = drawable.getMinWidth();
float regionHeight = drawable.getMinHeight();
float width = getWidth();
float height = getHeight();
Vector2 size = scaling.apply(regionWidth, regionHeight, width, height);
imageWidth = size.x;
imageHeight = size.y;
if ((align & Align.left) != 0)
imageX = 0;
else if ((align & Align.right) != 0)
imageX = (int) (width - imageWidth);
else
imageX = (int) (width / 2 - imageWidth / 2);
if ((align & Align.top) != 0)
imageY = (int) (height - imageHeight);
else if ((align & Align.bottom) != 0)
imageY = 0;
else
imageY = (int) (height / 2 - imageHeight / 2);
}
use of com.badlogic.gdx.math.Vector2 in project libgdx by libgdx.
the class Box2DCharacterControllerTest method createEdge.
private Body createEdge(BodyType type, float x1, float y1, float x2, float y2, float density) {
BodyDef def = new BodyDef();
def.type = type;
Body box = world.createBody(def);
EdgeShape poly = new EdgeShape();
poly.set(new Vector2(0, 0), new Vector2(x2 - x1, y2 - y1));
box.createFixture(poly, density);
box.setTransform(x1, y1, 0);
poly.dispose();
return box;
}
use of com.badlogic.gdx.math.Vector2 in project libgdx by libgdx.
the class Box2DCharacterControllerTest method createPlayer.
private Body createPlayer() {
BodyDef def = new BodyDef();
def.type = BodyType.DynamicBody;
Body box = world.createBody(def);
PolygonShape poly = new PolygonShape();
poly.setAsBox(0.45f, 1.4f);
playerPhysicsFixture = box.createFixture(poly, 1);
poly.dispose();
CircleShape circle = new CircleShape();
circle.setRadius(0.45f);
circle.setPosition(new Vector2(0, -1.4f));
playerSensorFixture = box.createFixture(circle, 0);
circle.dispose();
box.setBullet(true);
return box;
}
use of com.badlogic.gdx.math.Vector2 in project libgdx by libgdx.
the class PathTest method create.
@Override
public void create() {
renderer = new ImmediateModeRenderer20(false, false, 0);
spriteBatch = new SpriteBatch();
obj = new Sprite(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
obj.setSize(40, 40);
obj.setOriginCenter();
obj2 = new Sprite(new Texture(Gdx.files.internal("data/bobrgb888-32x32.png")));
obj2.setSize(40, 40);
obj2.setOriginCenter();
// 96DP
ZIGZAG_SCALE = Gdx.graphics.getDensity() * 96;
float w = Gdx.graphics.getWidth() - obj.getWidth();
float h = Gdx.graphics.getHeight() - obj.getHeight();
paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, h)));
paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(0, h), new Vector2(w, h)));
paths.add(new Bezier<Vector2>(new Vector2(0, 0), new Vector2(w, 0), new Vector2(0, h), new Vector2(w, h)));
Vector2[] cp = new Vector2[] { new Vector2(0, 0), new Vector2(w * 0.25f, h * 0.5f), new Vector2(0, h), new Vector2(w * 0.5f, h * 0.75f), new Vector2(w, h), new Vector2(w * 0.75f, h * 0.5f), new Vector2(w, 0), new Vector2(w * 0.5f, h * 0.25f) };
paths.add(new BSpline<Vector2>(cp, 3, true));
paths.add(new CatmullRomSpline<Vector2>(cp, true));
pathLength = paths.get(currentPath).approxLength(500);
avg_speed = speed * pathLength;
Gdx.input.setInputProcessor(this);
}
Aggregations