public TouchableEntity getTouchableEntity(AgentEntity agentEntity) { TouchableEntity touchableEntity = new TouchableEntity(); DamageEffect damageEffect = new DamageEffect(); damageEffect.setDamage(damage); damageEffect.setOriginatingAgent(agentEntity); touchableEntity.setCollisionPolygon(new Polygon(attackPolygon.getVertices())); Vector2 attackPosition = new Vector2(); if (agentEntity.isFacingLeft()) { attackPosition .add(agentEntity.getLeftBoundingSide()) .sub(attackPolygon.getBoundingRectangle().width, 0); } else { attackPosition.add(agentEntity.getRightBoundingSide()); } touchableEntity.setPosition(attackPosition); return touchableEntity; }
public void createPolygon(AgentEntity agentEntity) { Rectangle boundingBox = agentEntity.getCollisionPolygon().getBoundingRectangle(); attackPolygon = new Polygon(new float[] {0, 0, 0, boundingBox.height, 1, boundingBox.height, 1, 0}); }