本文整理汇总了Java中net.mostlyoriginal.api.component.physics.Attached类的典型用法代码示例。如果您正苦于以下问题:Java Attached类的具体用法?Java Attached怎么用?Java Attached使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Attached类属于net.mostlyoriginal.api.component.physics包,在下文中一共展示了Attached类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
@Override
protected void initialize() {
super.initialize();
aActor = newType(Pos.class, Bounds.class, Anim.class, Renderable.class);
aHamster = newSubType(aActor, PlayerControlled.class, Physics.class, Clamped.class, Ripple.class);
aBubble = newSubType(aActor, Attached.class, Color.class);
aOcean = newSubType(aActor, LiquidVolume.class);
aSky = newSubType(aActor, LiquidVolume.class);
aBuoy = newSubType(aActor, Physics.class);
Entity hamster = createEntity("hamster", 10, 10, null);
Entity ocean = createEntity("ocean");
Entity sky = createEntity("sky");
// hook up entities.
mClamped.get(hamster).maxx = G.SCREEN_WIDTH;
mClamped.get(hamster).maxy = G.SCREEN_HEIGHT * 0.6f;
}
示例2: process
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
@Override
protected void process(int e) {
final Attached attached = am.get(e);
final int parent = attached.parent;
if (parent != -1) {
// move attachment to absolute position, adjusted with slack.
Pos pos = pm.get(e);
Pos parPos = pm.get(parent);
pos.xy.x = parPos.xy.x + attached.xo + attached.slackX;
pos.xy.y = parPos.xy.y + attached.yo + attached.slackY;
updateSlack(attached);
} else {
// parent gone? we gone!
world.delete(e);
}
}
示例3: process
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
@Override
protected void process(Entity e) {
final Attached attached = am.get(e);
if (attached.parent.isActive()) {
// move attachment to absolute position, adjusted with slack.
Pos pos = pm.get(e);
Pos parPos = pm.get(attached.parent.get());
pos.x = parPos.x + attached.xo + attached.slackX;
pos.y = parPos.y + attached.yo + attached.slackY;
updateSlack(attached);
} else {
// parent gone? we gone!
e.deleteFromWorld();
}
}
示例4: process
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
@Override
protected void process(int e) {
final Homing homing = hm.get(e);
final int homingTarget = homing.target;
if (homingTarget != -1) {
final float distance = distance(e, homingTarget);
if (distance < homing.maxDistance) {
final Pos myPos = pm.get(e);
final Pos tPos = pm.get(homingTarget);
// vector of required traversal
tmp.set(tPos.xy.x, tPos.xy.y).sub(myPos.xy.x, myPos.xy.y).scl(homing.speedFactor);
if (ym.has(e)) {
Physics physics = ym.get(e);
physics.vx = tmp.x;
physics.vy = tmp.y;
}
if (am.has(e))
{
Attached attached = am.get(e);
attached.slackX = tmp.x;
attached.slackY = tmp.y;
}
}
} else homing.target = -1;
}
示例5: updateSlack
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
/**
* Slack, like weapon recoil on the joint.
*
* @param attached
*/
protected void updateSlack(final Attached attached) {
float len = vTmp.set(attached.slackX, attached.slackY).len() - world.delta * attached.tension;
if (len > 0) {
vTmp.nor().scl(len);
} else {
vTmp.set(0, 0);
}
attached.slackX = vTmp.x;
attached.slackY = vTmp.y;
}
示例6: process
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
@Override
protected void process(Entity e) {
final Homing homing = hm.get(e);
if (homing.target != null && homing.target.isActive()) {
final float distance = EntityUtil.distance(e, homing.target.get());
if (distance < homing.maxDistance) {
final Pos myPos = pm.get(e);
final Pos tPos = pm.get(homing.target.get());
// vector of required traversal
tmp.set(tPos.x + homing.xo, tPos.y + homing.yo).sub(myPos.x, myPos.y).scl(homing.speedFactor);
if (ym.has(e)) {
Physics physics = ym.get(e);
physics.vx = tmp.x;
physics.vy = tmp.y;
}
if (am.has(e))
{
Attached attached = am.get(e);
attached.slackX = tmp.x;
attached.slackY = tmp.y;
}
}
} else homing.target = null;
}
示例7: AttachmentSystem
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
public AttachmentSystem() {
super(Aspect.all(Pos.class, Attached.class));
}
示例8: AttachmentSystem
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
public AttachmentSystem() {
super(Aspect.getAspectForAll(Pos.class, Attached.class));
}
示例9: push
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
/**
* Apply force on joint, pushing the attached entity out of place.
*
* @param attached Attached component of entity to push
* @param rotation Direction of force
* @param force strength of force (don't factor in delta).
*/
public void push(final Attached attached, float rotation, float force) {
vTmp.set(force, 0).rotate(rotation).add(attached.slackX, attached.slackY).clamp(0f, attached.maxSlack);
attached.slackX = vTmp.x;
attached.slackY = vTmp.y;
}
示例10: push
import net.mostlyoriginal.api.component.physics.Attached; //导入依赖的package包/类
/**
* Apply force on joint, pushing the attached entity out of place.
*
* @param Attached Attached component of entity to push
* @param rotation Direction of force
* @param force strength of force (don't factor in delta).
*/
public void push(final Attached attached, float rotation, float force) {
vTmp.set(force, 0).rotate(rotation).add(attached.slackX, attached.slackY).clamp(0f, attached.maxSlack);
attached.slackX = vTmp.x;
attached.slackY = vTmp.y;
}