本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Payload方法的典型用法代码示例。如果您正苦于以下问题:Java DragAndDrop.Payload方法的具体用法?Java DragAndDrop.Payload怎么用?Java DragAndDrop.Payload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop
的用法示例。
在下文中一共展示了DragAndDrop.Payload方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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){
//
}*/
}
示例5: 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;
}
示例6: 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;
// }
}
示例7: DefaultDragAndDropTarget
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入方法依赖的package包/类
public DefaultDragAndDropTarget () {
dummyTarget = new DragAndDrop.Target(new Actor()) {
@Override
public boolean drag (DragAndDrop.Source source, DragAndDrop.Payload payload, float x, float y, int pointer) {
return false;
}
@Override
public void drop (DragAndDrop.Source source, DragAndDrop.Payload payload, float x, float y, int pointer) {
}
};
}
示例8: setBuild
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入方法依赖的package包/类
public void setBuild(boolean build, TowerObject rangeTower, DragAndDrop.Payload payload) {//
isBuild = build;
this.rangeTower = rangeTower;
this.payload = payload;
}
示例9: reset
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入方法依赖的package包/类
@Override
public void reset(DragAndDrop.Source source, DragAndDrop.Payload payload) {
getActor().setColor(Color.GREEN);
}
示例10: 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) {
getActor().setColor(Color.WHITE);
return true;
}
示例11: drop
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入方法依赖的package包/类
@Override
public void drop(DragAndDrop.Source source, DragAndDrop.Payload payload, float x, float y, int pointer) {
}
示例12: reset
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入方法依赖的package包/类
@Override
public void reset(DragAndDrop.Source source, DragAndDrop.Payload payload) {
}
示例13: drop
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop; //导入方法依赖的package包/类
@Override
public void drop(DragAndDrop.Source source, DragAndDrop.Payload payload, float x, float y, int pointer) {
}