當前位置: 首頁>>代碼示例>>Java>>正文


Java Actor.localToStageCoordinates方法代碼示例

本文整理匯總了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);

    }

}
 
開發者ID:whitecostume,項目名稱:libgdx_ui_editor,代碼行數:50,代碼來源:SelectGroup.java

示例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));
}
 
開發者ID:MrStahlfelge,項目名稱:gdx-controllerutils,代碼行數:7,代碼來源:ControllerMenuStage.java

示例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);
}
 
開發者ID:MrStahlfelge,項目名稱:gdx-controllerutils,代碼行數:7,代碼來源:ControllerMenuStage.java

示例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);
}
 
開發者ID:MrStahlfelge,項目名稱:gdx-controllerutils,代碼行數:50,代碼來源:ControllerMenuStage.java


注:本文中的com.badlogic.gdx.scenes.scene2d.Actor.localToStageCoordinates方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。