本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop类的典型用法代码示例。如果您正苦于以下问题:Java DragAndDrop类的具体用法?Java DragAndDrop怎么用?Java DragAndDrop使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DragAndDrop类属于com.badlogic.gdx.scenes.scene2d.utils包,在下文中一共展示了DragAndDrop类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: builder
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
static DragAndDrop.Source builder(final Actor actor){
return new DragAndDrop.Source(actor) {
@Override
public DragAndDrop.Payload dragStart(InputEvent event, float x, float y, int pointer) {
DragAndDrop.Payload payload = new DragAndDrop.Payload();
payload.setDragActor(new Label(actor.getName(), VisUI.getSkin()));
final Label validLabel = new Label(actor.getName(), VisUI.getSkin());
validLabel.setColor(Color.BLUE);
payload.setValidDragActor(validLabel);
final Label invalidLabel = new Label(actor.getName(), VisUI.getSkin());
invalidLabel.setColor(Color.RED);
payload.setInvalidDragActor(invalidLabel);
return payload;
}
};
}
示例2: dragStart
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
@Override
public DragAndDrop.Payload dragStart(InputEvent event, float x, float y, int pointer) {
// if(sourceSlot.isEmpty())return payload;
TowerObject tower = (TowerObject) sourceSlot.getLast();
DragAndDrop.Payload payload = super.dragStart(event, x, y, pointer);
if (payload == null)return null;
Level.getMap().setBuild(true, tower, payload); //start drawing build grid
Image i = ((Image)payload.getValidDragActor());//nullPointer
Image inv = ((Image)payload.getDragActor());
TextureRegionDrawable t = new TextureRegionDrawable(new TextureRegion(tower.getPrototype().getTowerTexture()));
i.setDrawable(t);
inv.setDrawable(t);
dragAndDrop.setDragActorPosition(-i.getWidth()/2, i.getHeight()/2);
return payload;
}
示例3: dragStop
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
@Override
public void dragStop(InputEvent event, float x, float y, int pointer, DragAndDrop.Payload payload, DragAndDrop.Target target) {
Level.getMap().setBuild(false, null, null);// end drawing build grid
super.dragStop(event, x, y, pointer, payload, target);
if (target instanceof TileTarget) {
TowerObject tower = ((TowerObject) payloadSlot.getLast());
if (tower != null) {
// Build
MapTile targetTile = ((MapTileActor) target.getActor()).getMapTile();
if(targetTile.build(tower)) {
// if (amount > 1) {
// sourceSlot.add(item, amount - 1);
// }
}else {
sourceSlot.add(payloadSlot.takeAll());
// return;
}
}
}
}
示例4: OverallInventory
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
public OverallInventory(Inventory[] customInventories){
super(GDefence.getInstance().assetLoader.getWord("arsenal"), GDefence.getInstance().assetLoader.getSkin(), "description");
getTitleLabel().setAlignment(Align.center);
setMovable(false);
dragAndDrop = new DragAndDrop();
AssetLoader l = GDefence.getInstance().assetLoader;
actors = new InventoryActor[3];
actors[0] = new InventoryActor(customInventories[0], dragAndDrop,
l.getSkin());
actors[0].getTitleLabel().setText(l.getWord("towers"));
actors[1] = new InventoryActor(customInventories[1], dragAndDrop,
l.getSkin());
actors[1].getTitleLabel().setText(l.getWord("spells"));
actors[2] = new InventoryActor(customInventories[2], dragAndDrop,
l.getSkin());
actors[2].getTitleLabel().setText(l.getWord("details"));
createButtons();
}
示例5: InventoryActor
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
public InventoryActor(Inventory inventory, DragAndDrop dragAndDrop, Skin skin) {
super(GDefence.getInstance().assetLoader.getWord("towers"), skin, "description");
getTitleLabel().setAlignment(Align.center);
setMovable(false);
this.inventory = inventory;
this.dragAndDrop = dragAndDrop;
this.dragAndDrop.setButton(-1);
this.dragAndDrop.setTapSquareSize(2);
this.dragAndDrop.setDragTime(30);
this.skin = skin;
//TextButton closeButton = new TextButton("X", skin);
//closeButton.addListener(new HidingClickListener(this));
//add(closeButton).height(getPadTop());//
//getButtonTable().add(closeButton).height(getPadTop());
setDefaults();
initCells(/*dragAndDrop, */skin, inventory);//
pack();
//setVisible(false);
setVisible(true);
}
示例6: ArkScreen
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
public ArkScreen(Skin uiSkin, InputMultiplexer multiplexer) {
ani = new Ani();
skin = uiSkin;
this.multiplexer = multiplexer;
spriteBatch = new SpriteBatch();
stage = new Stage();
dragAndDrop = new DragAndDrop();
App.TUTORIAL_CONTROLLER.register(stage, ani);
App.TUTORIAL_CONTROLLER.nextStepFor(this.getClass());
fuelProgressBar = new ShipProgressBar(ShipProgressBar.ProgressType.FUEL);
fuelProgressBar.updateFromShipProperties();
shieldProgressBar = new ShipProgressBar(ShipProgressBar.ProgressType.SHIELD);
shieldProgressBar.updateFromShipProperties();
stage.addActor(fuelProgressBar);
stage.addActor(shieldProgressBar);
}
示例7: TasktableActor
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
public TasktableActor(DragAndDrop dragAndDrop, Skin skin) {
super("Aktivitäten", skin);
Table table = new Table();
setTable(skin, table, "scrollPaneWindowTasksCalendar");
for (Slot slot : tasktable.getSlots()) {
SlotActor slotActor = new SlotActor(skin, slot);
dragAndDrop.addSource(new SlotSource(slotActor));
dragAndDrop.addTarget(new SlotTarget(slotActor));
dragAndDrop.setDragActorPosition(-CalendarScreen.WIDTHTASK / 2, CalendarScreen.HEIGHTTASK / 2);
table.add(slotActor).width(CalendarScreen.WIDTHTASK).height(CalendarScreen.HEIGHTTASK);
table.row().padTop(5);
}
getScrollTable().setFlickScroll(false);
getScrollTable().setFadeScrollBars(false);
setBounds(AppMain.WIDTH - 212, 70, 210, AppMain.HEIGHT - 72);
setMovable(false);
pad(8);
}
示例8: AnimationEdition
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
public AnimationEdition(Controller controller) {
super();
skin = controller.getApplicationAssets().getSkin();
align(Align.top);
DragAndDrop dragAndDrop = new DragAndDrop();
buttonReg = new HashMap<IconTextButton, Class<Effect>>();
drawableReg = new HashMap<Class<Effect>, Drawable>();
backgroundTweens = skin.getDrawable("bg-dark");
add(new TweensTypeTab(dragAndDrop, controller)).left();
row();
AnimationTimeline timeline = new AnimationTimeline(dragAndDrop,
controller);
add(timeline).expandX().fill();
row();
add(new Separator(true, skin));
row();
add(timeline.getAddButton()).fill().expandX();
row();
add(new Separator(true, skin));
}
示例9: init
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
public void init(){
//Skin skin = LibgdxUtils.assets.get("skins/uiskin.json", Skin.class);
// inventoryActor = new InventoryActor(User.getTowerInventory(), new DragAndDrop(),
// GDefence.getInstance().assetLoader.get("skins/uiskin.json", Skin.class));
inventoryActor = new OverallInventory();
stage.addActor(inventoryActor);
inventoryActor.init();
inventoryActor.setPosition(100, 250);
towerMap = new TowerMap(GDefence.getInstance().assetLoader.getSkin());
GDefence.getInstance().user.setTowerMap(towerMap);
stage.addActor(towerMap);
final TextButton towerMapButton = new TextButton(GDefence.getInstance().assetLoader.getWord("tower_map"), GDefence.getInstance().assetLoader.getSkin(), "description");
towerMapButton.setPosition(Gdx.graphics.getWidth() - 200, Gdx.graphics.getHeight() - 100);
towerMapButton.setSize(140, 40);
towerMapButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
towerMap.setVisible(true);
towerMap.toFront();
return true;
}
});
stage.addActor(towerMapButton);
TowerCraftPanel towerCraftPanel = new TowerCraftPanel(new DragAndDrop(), inventoryActor, GDefence.getInstance().assetLoader.getSkin());
stage.addActor(towerCraftPanel);
towerCraftPanel.init();
// inventoryActor.addTarget(towerCraftPanel.getRecipeSlot());
// inventoryActor.addSlotAsSourceTarget(towerCraftPanel.getDragAndDrop());
}
示例10: TowerCraftPanel
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
public TowerCraftPanel(DragAndDrop dragAndDrop, OverallInventory overallInventory, Skin skin) {
super(GDefence.getInstance().assetLoader.getWord("craft_panel"), skin, "description");
getTitleLabel().setAlignment(Align.center);
setMovable(false);
setDefaults();
setResizable(false);
this.dragAndDrop = dragAndDrop;
this.skin = skin;
setSourceTargetInventory(overallInventory);
recipeSlot = new SlotActor(skin, new Slot(Recipe.class/*, null, 0*/));
recipeListener = new RecipeListener();
recipeSlot.getSlot().addListener(recipeListener);
// resultListener = new ResultListener();
resultSlot = new SlotActor(skin, new Slot(TowerObject.class/*, null, 0*/));
add(recipeSlot).align(Align.center);
row();
add();//3 max component size
add().size(0, 0);
add().size(0, 0);
row();
add();
pack();//delete this to do resizable
setSize(180, 250);
// recipeSlot.setRound(true);
// recipeSlot.setClip(false);
sourceTargetInventory.addTarget(recipeSlot);
dragAndDrop.addSource(new SlotSource(recipeSlot));
sourceTargetInventory.addSlotAsTarget(dragAndDrop);
componentSlots = new Array<SlotActor>();
componentListeners = new Array<ComponentListener>();
}
示例11: ifSlotTarget
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
@Override
protected void ifSlotTarget(DragAndDrop.Target target) {
Slot targetSlot = ((SlotActor) target.getActor()).getSlot();
if (targetSlot.matches(payloadSlot) || targetSlot.getPrototype() == null) {
targetSlot.add(payloadSlot.takeAll());
}
}
示例12: ifSlotTarget
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
@Override
protected void ifSlotTarget(DragAndDrop.Target target) {
Slot targetSlot = ((SlotActor) target.getActor()).getSlot();
if (!targetSlot.isFull() && (targetSlot.matches(payloadSlot) || targetSlot.getPrototype() == null)) {
Item item = sourceSlot.getPrototype();
if(GDefence.getInstance().user.deleteGold(item.getGlobalCost())){
targetSlot.add(payloadSlot.takeAll());
} else {
// System.out.println("No enough money");
}
} else {
//dont swap items
}
}
示例13: dragStop
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
@Override
public void dragStop(InputEvent event, float x, float y, int pointer, DragAndDrop.Payload payload, DragAndDrop.Target target) {
if (target instanceof SellTarget) {
Item item = payloadSlot.getPrototype();
int amount = payloadSlot.getAmount();
if (item != null) {
GDefence.getInstance().user.addGold(item.getGlobalCost() * amount);
} else {
GDefence.getInstance().log("SellSlotSource: Item - null");
}
return;
}
super.dragStop(event, x, y, pointer, payload, target);
/*else if(target instanceof GemGradeTarget){
Slot targetSlot = ((SlotActor) target.getActor()).getSlot();
if(targetSlot.isEmpty()){//targetSlot.getPrototype() == null
int noNeed = 0;
if (payloadSlot.getAmount() > 1){
noNeed = payloadSlot.getAmount() - 1;
}
targetSlot.add(payloadSlot.take(1));
if(noNeed > 0) {
sourceSlot.add(payloadSlot.takeAll());//all remaining
}
}
} else if(target instanceof TowerCraftTarget){
//
}*/
}
示例14: drag
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
@Override
public boolean drag(DragAndDrop.Source source, DragAndDrop.Payload payload, float x, float y, int pointer) {
// Image i = ((Image)payload.getDragActor());
//dragAndDrop.setDragActorPosition(-i.getWidth()/2, i.getHeight()/2);//not optimized
//TextureRegionDrawable t = new TextureRegionDrawable(new TextureRegion(AssetLoader.rockTower));
//i.setDrawable(t);
//Level.getMap().setRangeTower(payload.getDragActor().getX(), payload.getDragActor().getY());
return true;
}
示例15: drag
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入依赖的package包/类
@Override
public boolean drag(DragAndDrop.Source source, DragAndDrop.Payload payload, float x, float y, int pointer) {
Slot payloadSlot = (Slot) payload.getObject();
// if (targetSlot.getPrototype() == payloadSlot.getPrototype() ||
// targetSlot.getPrototype() == null) {
getActor().setColor(Color.WHITE);
return true;
// } else {
// getActor().setColor(Color.DARK_GRAY);
// return false;
// }
}