Java 类com.badlogic.gdx.scenes.scene2d.utils.DragListener 实例源码

项目:dice-heroes    文件:ViewScroller.java   
public ViewScroller(ViewController viewController) {
    this.viewController = viewController;
    stage = viewController.world.stage;
    root = viewController.root;

    hScrollEnabled = root.getWidth() > stage.getWidth() - LEFT - RIGHT;
    vScrollEnabled = root.getHeight() > stage.getHeight() - BOTTOM - TOP;

    minRootX = stage.getWidth() - RIGHT - root.getWidth();
    maxRootX = LEFT;
    minRootY = stage.getHeight() - TOP - root.getHeight();
    maxRootY = BOTTOM;

    stage.addListener(listener = new DragListener() {
        {
            setTapSquareSize(8);
        }

        @Override public void drag(InputEvent event, float x, float y, int pointer) {
            if (!enabled)
                return;
            if (!event.getTarget().isDescendantOf(root) && event.getTarget() != stage.getRoot())
                return;
            if (hScrollEnabled) root.setX(MathUtils.clamp(root.getX() - getDeltaX(), minRootX, maxRootX));
            if (vScrollEnabled) root.setY(MathUtils.clamp(root.getY() - getDeltaY(), minRootY, maxRootY));
        }
    });
}
项目:umbracraft    文件:UmbraDragAndDrop.java   
/** Removes all targets and sources. */
public void clear() {
    targets.clear();
    for (Entry<Source, DragListener> entry : sourceListeners.entries()) {
        entry.key.actor.removeCaptureListener(entry.value);
    }
    sourceListeners.clear();
}
项目:vis-editor    文件:VisDragAndDrop.java   
/** Removes all targets and sources. */
public void clear () {
    targets.clear();
    for (Entry<Source, DragListener> entry : sourceListeners.entries())
        entry.key.getActor().removeCaptureListener(entry.value);
    sourceListeners.clear();
}
项目:Climatar    文件:MapView.java   
@Override
public void build(Group group) {
    WorldMap world = MapGenerator.generateMap(4, 14, 7, 4);

    map = new DrawableMap(world, 0.4f);

    table = new VisTable();
    table.add(map);

    group.addActor(table);

    group.addListener(new DragListener() {
        @Override
        public void drag(InputEvent event, float x, float y, int pointer) {
            float dragDistanceX = -1*getDeltaX() / map.getScale();
            float dragDistanceY = -1*getDeltaY() / map.getScale();

            float posX = map.getX();
            float posY = map.getY();

            float maxWidth = map.getFrame().width / map.getScale();
            float maxHeight = map.getFrame().height / map.getScale();

            float textureWidth = map.getWidth();
            float textureHeight = map.getHeight();

            float newPosY = posY + dragDistanceY;

            if (map.getVerticalMapSize() == MapSize.SMALLER_THAN_VIEWPORT) {
                if (newPosY < 0)
                    newPosY = 0;
                if (newPosY > maxHeight - textureHeight)
                    newPosY = maxHeight - textureHeight;

                map.setY(newPosY);
            } else if (map.getVerticalMapSize() == MapSize.BIGGER_THAN_VIEWPORT) {
                if (newPosY > 0)
                    newPosY = 0;
                if (newPosY < maxHeight - textureHeight)
                    newPosY = maxHeight - textureHeight;

                map.setY(newPosY);
            }

            float newPosX = posX + dragDistanceX;
            if (map.getHorizontalMapSize() == MapSize.SMALLER_THAN_VIEWPORT) {
                if (newPosX < 0)
                    newPosX = 0;
                if (newPosX > maxWidth - textureWidth)
                    newPosX = maxWidth - textureWidth;

                map.setX(newPosX);
            } else if (map.getHorizontalMapSize() == MapSize.BIGGER_THAN_VIEWPORT) {
                if (newPosX > 0)
                    newPosX = 0;
                if (newPosX < maxWidth - textureWidth)
                    newPosX = maxWidth - textureWidth;

                map.setX(newPosX);
            }
        }
    });
}
项目:umbracraft    文件:UmbraDragAndDrop.java   
public void removeSource(Source source) {
    DragListener dragListener = sourceListeners.remove(source);
    source.actor.removeCaptureListener(dragListener);
}
项目:vis-editor    文件:VisDragAndDrop.java   
public void removeSource (Source source) {
    DragListener dragListener = sourceListeners.remove(source);
    source.getActor().removeCaptureListener(dragListener);
}
项目:spezi-gdx    文件:DragAndDrop.java   
public void removeSource(Source source) {
    DragListener dragListener = sourceListeners.remove(source);
    source.actor.removeCaptureListener(dragListener);
}