本文整理汇总了Java中com.badlogic.gdx.physics.box2d.Transform类的典型用法代码示例。如果您正苦于以下问题:Java Transform类的具体用法?Java Transform怎么用?Java Transform使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transform类属于com.badlogic.gdx.physics.box2d包,在下文中一共展示了Transform类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCameraActuator
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public ActuatorEntity addCameraActuator(Camera camera, short height,
float damping, float minDistanceX, float minDistanceY,
String followTagEntity) {
CameraActuator component = (CameraActuator) recoverComponent(ActuatorComponentsLookup.CameraActuator);
if (component == null) {
component = new CameraActuator(camera, height, damping,
minDistanceX, minDistanceY, followTagEntity);
} else {
component.actuator = (indexOwner) -> {
Set<GameEntity> followEntities = Indexed
.getTagEntities(followTagEntity);
for (GameEntity followEntity : followEntities) {
RigidBody rc = followEntity.getRigidBody();
Transform transform = rc.body.getTransform();
Vector3 position = camera.position;
position.x += (transform.getPosition().x + minDistanceX - position.x)
* damping;
position.y += (transform.getPosition().y + minDistanceY - position.y)
* height;
}
};
}
addComponent(ActuatorComponentsLookup.CameraActuator, component);
return this;
}
示例2: replaceCameraActuator
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public ActuatorEntity replaceCameraActuator(Camera camera, short height,
float damping, float minDistanceX, float minDistanceY,
String followTagEntity) {
CameraActuator component = (CameraActuator) recoverComponent(ActuatorComponentsLookup.CameraActuator);
if (component == null) {
component = new CameraActuator(camera, height, damping,
minDistanceX, minDistanceY, followTagEntity);
} else {
component.actuator = (indexOwner) -> {
Set<GameEntity> followEntities = Indexed
.getTagEntities(followTagEntity);
for (GameEntity followEntity : followEntities) {
RigidBody rc = followEntity.getRigidBody();
Transform transform = rc.body.getTransform();
Vector3 position = camera.position;
position.x += (transform.getPosition().x + minDistanceX - position.x)
* damping;
position.y += (transform.getPosition().y + minDistanceY - position.y)
* height;
}
};
}
replaceComponent(ActuatorComponentsLookup.CameraActuator, component);
return this;
}
示例3: addParticleEffectActuator
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public ActuatorEntity addParticleEffectActuator(ParticleEffect effect,
boolean autoStart, float locaPosX, float locaPosY) {
ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
if (component == null) {
component = new ParticleEffectActuator(effect, autoStart, locaPosX,
locaPosY);
} else {
component.particleEffect = effect;
component.actuator = (indexOwner) -> {
GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
RigidBody rc = owner.getRigidBody();
Transform transform = rc.body.getTransform();
effect.setPosition(transform.getPosition().x + locaPosX,
transform.getPosition().y + locaPosY);
effect.update(Gdx.graphics.getDeltaTime());
if (autoStart && effect.isComplete())
effect.start();
};
}
addComponent(ActuatorComponentsLookup.ParticleEffectActuator, component);
return this;
}
示例4: replaceParticleEffectActuator
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public ActuatorEntity replaceParticleEffectActuator(ParticleEffect effect,
boolean autoStart, float locaPosX, float locaPosY) {
ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
if (component == null) {
component = new ParticleEffectActuator(effect, autoStart, locaPosX,
locaPosY);
} else {
component.particleEffect = effect;
component.actuator = (indexOwner) -> {
GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
RigidBody rc = owner.getRigidBody();
Transform transform = rc.body.getTransform();
effect.setPosition(transform.getPosition().x + locaPosX,
transform.getPosition().y + locaPosY);
effect.update(Gdx.graphics.getDeltaTime());
if (autoStart && effect.isComplete())
effect.start();
};
}
replaceComponent(ActuatorComponentsLookup.ParticleEffectActuator,
component);
return this;
}
示例5: processActuator
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
@Override
public void processActuator(CameraActuator actuator, float deltaTime) {
Entity target = null;
if(actuator.followEntity != null)
target = actuator.followEntity;
else if(actuator.followTagEntity != null)
actuator.followEntity = target = engine.getEntities(actuator.followTagEntity).first();
if(target != null) {
RigidBodiesComponents rc = target.getComponent(RigidBodiesComponents.class);
Transform transform = rc.rigidBodies.first().getTransform();
Vector3 position = actuator.camera.position;
position.x += (transform.getPosition().x - position.x) * actuator.damping;
position.y += (transform.getPosition().y - position.y) * actuator.damping;
}
}
示例6: ComputeSubmergedArea
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public static float ComputeSubmergedArea(CircleShape shape, Vector2 normal, float offset, Transform xf, Vector2 c)
{
Vector2 p = xf.mul(shape.getPosition());
float l = -(normal.dot(p) - offset);
float r = shape.getRadius();
if (l < -r)
{ // Completely dry
return 0;
}
if (l > r)
{ // Completely wet
c.set(p);
return MathUtils.PI * r * r;
}
float r2 = r * r;
float l2 = l * l;
float area = r2 * ((float) Math.asin(l / r) + MathUtils.PI / 2) + l * (float) Math.sqrt(r2 - l2);
float com = -2.0f / 3.0f * (float) Math.pow(r2 - l2, 1.5f) / area;
c.x = p.x + normal.x * com;
c.y = p.y + normal.y * com;
return area;
}
示例7: ComputeSubmergedArea
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public static float ComputeSubmergedArea(CircleShape shape, Vector2 normal, float offset, Transform xf, Vector2 c)
{
Vector2 p = xf.mul(shape.getPosition());
float l = -(normal.dot(p) - offset);
float r = shape.getRadius();
if (l < -r)
{ // Completely dry
return 0;
}
if (l > r)
{ // Completely wet
c.set(p);
return MathUtils.PI * r * r;
}
float r2 = r * r;
float l2 = l * l;
float area = r2 * ((float) Math.asin(l / r) + MathUtils.PI / 2) + l * (float) Math.sqrt(r2 - l2);
float com = -2.0f / 3.0f * (float) Math.pow(r2 - l2, 1.5f) / area;
c.x = p.x + normal.x * com;
c.y = p.y + normal.y * com;
return area;
}
示例8: CameraActuator
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public CameraActuator(Camera camera, short height, float damping, float minDistanceX, float minDistanceY, String followTagEntity) {
this.actuator = (indexOwner) -> {
Set<GameEntity> followEntities = Indexed.getTagEntities(followTagEntity);
for (GameEntity followEntity : followEntities) {
RigidBody rc = followEntity.getRigidBody();
Transform transform = rc.body.getTransform();
Vector3 position = camera.position;
position.x += (transform.getPosition().x + minDistanceX - position.x) * damping;
position.y += (transform.getPosition().y + minDistanceY - position.y) * height;
}
};
}
示例9: ParticleEffectActuator
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public ParticleEffectActuator(ParticleEffect effect, boolean autoStart, float locaPosX, float locaPosY) {
this.particleEffect = effect;
this.actuator = (indexOwner)-> {
GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
RigidBody rc = owner.getRigidBody();
Transform transform = rc.body.getTransform();
effect.setPosition(transform.getPosition().x + locaPosX, transform.getPosition().y + locaPosY);
effect.update(Gdx.graphics.getDeltaTime());
if(autoStart && effect.isComplete()) effect.start();
};
}
示例10: createContext
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
@Override
protected void createContext() {
// Create Player Entity
entityBuilder.initialize();
IdentityComponent identityPlayer = entityBuilder.getComponent(IdentityComponent.class);
identityPlayer.tag = "Player";
transform = new Transform(new Vector2(), 0);
/* TextureView view = new TextureView();
view.attachedTransform = transform;
view.width = 4;
view.height = 3;
entityBuilder.getComponent(ViewsComponent.class).views.add(view);
*/
sensor =builders.getBrickBuilder(MouseSensorBuilder.class)
.setMouseEvent(MouseSensor.MouseEvent.MOVEMENT)
.setName("sensorPlayer")
.getBrick();
ConditionalController controllerGround =builders.getBrickBuilder(ConditionalControllerBuilder.class)
.setOp(ConditionalController.Op.OP_AND)
.getBrick();
ActuatorTest actuatorTest = new ActuatorTest();
player = entityBuilder
.addController(controllerGround, "Default")
.connectToSensor(sensor)
.connectToActuator(actuatorTest)
.getEntity();
sensorSystem = engine.getSystem(MouseSensorSystem.class);
}
示例11: drawDebug
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
/**
* Draws body lines and AABB.
* @param camera Specify which game camera you want.
*/
@Override
public void drawDebug(FlxCamera camera)
{
if(B2FlxDebug.drawBodies || B2FlxDebug.drawAABBs)
{
if (body.isActive() && B2FlxDebug.drawInactiveBodies)
return;
Transform transform = body.getTransform();
if(B2FlxDebug.drawBodies)
{
for(int i = 0; i < _fixtures.size; i++)
{
_fixtureDebug = _fixtures.get(i);
if(body.isActive() == false)
drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_NOT_ACTIVE);
else if(body.getType() == BodyType.StaticBody)
drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_STATIC);
else if(body.getType() == BodyType.KinematicBody)
drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_KINEMATIC);
else if(body.isAwake() == false)
drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_NOT_AWAKE);
else
drawShape(_fixtureDebug, transform, B2FlxDebug.SHAPE_AWAKE);
if(B2FlxDebug.drawAABBs)
{
if(_fixtureDebug.getType() != Type.Edge && _fixtureDebug.getType() != Type.Chain)
drawAABB(_fixtureDebug, transform);
}
}
}
}
}
示例12: setAttachedTransform
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public View setAttachedTransform(Transform attachedTransform) {
this.attachedTransform = attachedTransform;
return this;
}
示例13: getBodyPixelCoord
import com.badlogic.gdx.physics.box2d.Transform; //导入依赖的package包/类
public Vector2 getBodyPixelCoord (Body b) {
Transform xf = b.getTransform();
return coordWorldToPixels(xf.getPosition());
}