use of com.badlogic.gdx.math.Vector2 in project Entitas-Java by Rubentxu.
the class CoreEntity method replaceMotion.
public CoreEntity replaceMotion(float x, float y) {
Motion component = (Motion) recoverComponent(CoreComponentsLookup.Motion);
if (component == null) {
component = new Motion(x, y);
} else {
component.velocity = new Vector2(x, y);
}
replaceComponent(CoreComponentsLookup.Motion, component);
return this;
}
use of com.badlogic.gdx.math.Vector2 in project Entitas-Java by Rubentxu.
the class AddViewSystem method execute.
@Override
public void execute(List<GameEntity> entities) {
for (GameEntity e : entities) {
Texture texture = assetsManager.getTexture(String.format("assets/textures/%1$s.png", e.getAsset().name));
Body body = bodyBuilder.fixture(new FixtureDefBuilder().boxShape(0.5f, 0.5f)).type(BodyDef.BodyType.KinematicBody).build();
TextureRegion textureRegion = new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
e.addTextureView(e.getAsset().name, textureRegion, body);
//
if (e.hasPosition()) {
Position pos = e.getPosition();
body.setTransform(new Vector2(pos.x, pos.y + 1), 0);
}
}
}
use of com.badlogic.gdx.math.Vector2 in project Entitas-Java by Rubentxu.
the class PointerOverSensorSystem method isOver.
private boolean isOver(PointerOverSensor sensor, int pointer) {
PointerState<Vector2, Vector3> touchState = inputManager.getTouchState(pointer);
if (touchState.down) {
Set<GameEntity> targets = Indexed.getTagEntities(sensor.targetTag);
for (GameEntity target : targets) {
TextureView view = target.getTextureView();
RigidBody rigidBody = target.getRigidBody();
if (view != null && rigidBody != null) {
testRectangle.setPosition(rigidBody.body.getPosition().x, rigidBody.body.getPosition().y);
testRectangle.setSize(view.bounds.extentsX * 2, view.bounds.extentsY * 2);
return testRectangle.contains(touchState.coordinates.x, touchState.coordinates.y);
}
}
}
return false;
}
use of com.badlogic.gdx.math.Vector2 in project Entitas-Java by Rubentxu.
the class PlatformExamples method createScene.
@Override
public void createScene(Engine engine, Entitas entitas) {
AssetsManagerGDX assetsManager = engine.getManager(AssetsManagerGDX.class);
assetsManager.loadTexture("assets/imagenes/fondos/fondo.jpg");
assetsManager.loadTexture("assets/imagenes/fondos/nubes.png");
assetsManager.loadTexture("assets/imagenes/fondos/arboles.png");
assetsManager.finishLoading();
// entitas.scene.createEntity()
// .addParallaxLayer(new TextureRegion(assetsManager.getTexture("assets/imagenes/fondos/fondo.jpg"))
// , new Vector2(0.7f,0f),new Vector2(0, 1),new Vector2(0, 0));
entitas.scene.createEntity().addParallaxLayer(new TextureRegion(assetsManager.getTexture("assets/imagenes/fondos/nubes.png")), new Vector2(0.5f, 1.0f), new Vector2(0, 10), new Vector2(0, 0));
entitas.scene.createEntity().addParallaxLayer(new TextureRegion(assetsManager.getTexture("assets/imagenes/fondos/arboles.png")), new Vector2(0.9f, 0), new Vector2(0, -0.4f), new Vector2(0, 0));
// entitas.scene.createEntity()
// .addCPointLight(55, Color.GOLD, 45, new Vector2(10,4));
// entitas.scene.createEntity()
// .addCChainLight(25, Color.FOREST, 180, 145, new float[]{-5, 0, 0, 0, 0, 0,30,12});
// entitas.scene.createEntity()
// .addCDirectionalLight(84, Color.SKY, 270);
entitas.scene.createEntity().addCConeLight(35, Color.GREEN, 40, new Vector2(16, 13), 250, 60);
SceneManagerGDX sceneManager = engine.getManager(SceneManagerGDX.class);
GameEntity ground = sceneManager.createEntity("Ground");
ground.getRigidBody().body.setTransform(10, 1, 0);
GameEntity mariano = sceneManager.createEntity("Mariano");
mariano.getRigidBody().body.setTransform(10, 6, 0);
GameEntity box1 = sceneManager.createEntity("Box");
box1.addTags("Box");
box1.getRigidBody().body.setTransform(20, 7, 0);
GameEntity box2 = sceneManager.createEntity("Box");
box2.addTags("Box2");
box2.getRigidBody().body.setTransform(25, 7, 0);
entitas.actuator.setDragActuator(ground.getCreationIndex(), false, 1000);
}
use of com.badlogic.gdx.math.Vector2 in project nhglib by VoidZombie.
the class InputHandler method processPointerInput.
private void processPointerInput(Integer pointer, NhgInput input) {
if (config != null) {
Vector2 axis = VectorPool.getVector2();
PointerInputConfiguration conf = config.getPointerConfiguration(input.getName());
switch(conf.getPointerSourceType()) {
case POINTER_DELTA_XY:
axis.set(Gdx.input.getDeltaX(pointer), Gdx.input.getDeltaY(pointer));
axis.scl(conf.getHorizontalSensitivity(), conf.getVerticalSensitivity());
break;
case POINTER_XY:
axis.set(Gdx.input.getX(pointer), Gdx.input.getY(pointer));
break;
}
InputSource inputSource = input.getInputSource();
inputSource.setName(input.getName());
inputSource.setValue(axis);
}
}
Aggregations