本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.Actor.localToStageCoordinates方法的典型用法代码示例。如果您正苦于以下问题:Java Actor.localToStageCoordinates方法的具体用法?Java Actor.localToStageCoordinates怎么用?Java Actor.localToStageCoordinates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.Actor
的用法示例。
在下文中一共展示了Actor.localToStageCoordinates方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initLayout
import com.badlogic.gdx.scenes.scene2d.Actor; //导入方法依赖的package包/类
public void initLayout(){
if (selection.size()<=0){
setVisible(false);
}else {
setVisible(true);
Array<Actor> actors = getAllActor();
Actor parentWindow = SelectGroup.this.getParent();
float x1=0,x2 = 0,y1=0,y2=0;
for (int i = 0; i <actors.size; i++) {
Actor actor = actors.get(i);
if (actor instanceof MainWindow){
x1 = 0;
x2 = actor.getWidth();
y1 = 0;
y2 = actor.getHeight();
break;
}
Vector2 posV = new Vector2(0,0);
Vector2 posV2 = new Vector2(actor.getWidth(),actor.getHeight());
posV = actor.localToStageCoordinates(posV);
posV2 = actor.localToStageCoordinates(posV2);
posV = parentWindow.stageToLocalCoordinates(posV);
posV2 = parentWindow.stageToLocalCoordinates(posV2);
float minX = Math.min(posV.x,posV2.x);
float maxX = Math.max(posV.x,posV2.x);
float minY = Math.min(posV.y,posV2.y);
float maxY = Math.max(posV.y,posV2.y);
if (i == 0){
x1 = minX;
x2 = maxX;
y1 = minY;
y2 = maxY;
}else {
if (minX<x1) x1 = minX;
if (maxX>x2) x2 = maxX;
if (minY<y1) y1 = minY;
if (maxY>y2) y2 = maxY;
}
}
SelectGroup.this.setBounds(x1,y1,x2 - x1,y2 - y1);
}
}
示例2: isActorHittable
import com.badlogic.gdx.scenes.scene2d.Actor; //导入方法依赖的package包/类
protected boolean isActorHittable(Actor actor) {
// Prüfung auf hit
Vector2 center = actor.localToStageCoordinates(new Vector2(actor.getWidth() / 2, actor.getHeight() / 2));
Actor hitActor = hit(center.x, center.y, true);
return hitActor != null && (hitActor.isDescendantOf(actor));
}
示例3: isActorInViewportArea
import com.badlogic.gdx.scenes.scene2d.Actor; //导入方法依赖的package包/类
protected boolean isActorInViewportArea(Actor actor) {
Vector2 leftBottom = actor.localToStageCoordinates(new Vector2(0, 0));
Vector2 rightTop = actor.localToStageCoordinates(new Vector2(actor.getWidth(), actor.getHeight()));
return !(leftBottom.x > getWidth() || leftBottom.y > getHeight() || rightTop.x < 0 || rightTop.y < 0);
}
示例4: moveFocusByDirection
import com.badlogic.gdx.scenes.scene2d.Actor; //导入方法依赖的package包/类
private boolean moveFocusByDirection(MoveFocusDirection direction) {
if (focussedActor == null)
return false;
Vector2 focussedPosition = focussedActor.localToStageCoordinates(
new Vector2(direction == MoveFocusDirection.east ? focussedActor.getWidth() :
direction == MoveFocusDirection.west ? 0 : focussedActor.getWidth() / 2,
direction == MoveFocusDirection.north ? focussedActor.getHeight() :
direction == MoveFocusDirection.south ? 0 : focussedActor.getHeight() / 2));
// in Frage kommende raussuchen
Actor nearestInDirection = null;
float distance = Float.MAX_VALUE;
for (int i = 0; i < focussableActors.size; i++) {
Actor currentActor = focussableActors.get(i);
if (currentActor != focussedActor && isActorFocussable(currentActor)
&& isActorInViewportArea(currentActor)) {
Vector2 currentActorPos = currentActor.localToStageCoordinates(
new Vector2(direction == MoveFocusDirection.west ? currentActor.getWidth() :
direction == MoveFocusDirection.east ? 0 : currentActor.getWidth() / 2,
direction == MoveFocusDirection.south ? currentActor.getHeight() :
direction == MoveFocusDirection.south ? 0 : currentActor.getHeight() / 2));
boolean isInDirection = false;
isInDirection = (direction == MoveFocusDirection.south && currentActorPos.y <= focussedPosition.y)
|| (direction == MoveFocusDirection.north && currentActorPos.y >= focussedPosition.y)
|| (direction == MoveFocusDirection.west && currentActorPos.x <= focussedPosition.x)
|| (direction == MoveFocusDirection.east && currentActorPos.x >= focussedPosition.x);
if (isInDirection && isActorHittable(currentActor)) {
float currentDist = currentActorPos.dst2(focussedPosition);
if (currentDist < distance) {
nearestInDirection = currentActor;
distance = currentDist;
}
}
}
}
if (nearestInDirection != null)
setFocussedActor(nearestInDirection);
return (nearestInDirection != null);
}