本文整理了Java中com.badlogic.gdx.scenes.scene2d.Actor.addListener()
方法的一些代码示例,展示了Actor.addListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Actor.addListener()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Actor
类名称:Actor
方法名:addListener
[英]Add a listener to receive events that #hit(float,float,boolean) this actor. See #fire(Event).
[中]添加一个侦听器以接收命中(float、float、boolean)此参与者的事件。参见#火灾(事件)。
代码示例来源:origin: libgdx/libgdx
public boolean act (float delta) {
if (capture)
target.addCaptureListener(listener);
else
target.addListener(listener);
return true;
}
代码示例来源:origin: libgdx/libgdx
public boolean act (float delta) {
if (capture)
target.addCaptureListener(listener);
else
target.addListener(listener);
return true;
}
代码示例来源:origin: libgdx/libgdx
public void setTarget (Actor newTarget) {
if (target != null) target.removeListener(listener);
super.setTarget(newTarget);
if (newTarget != null) newTarget.addListener(listener);
}
代码示例来源:origin: libgdx/libgdx
public void setTarget (Actor newTarget) {
if (target != null) target.removeListener(listener);
super.setTarget(newTarget);
if (newTarget != null) newTarget.addListener(listener);
}
代码示例来源:origin: libgdx/libgdx
public void create () {
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
Table table = new Table();
table.setFillParent(true);
stage.addActor(table);
final Tree tree = new Tree(skin);
final Node moo1 = new Node(new TextButton("moo1", skin));
final Node moo2 = new Node(new TextButton("moo2", skin));
final Node moo3 = new Node(new TextButton("moo3", skin));
final Node moo4 = new Node(new TextButton("moo4", skin));
final Node moo5 = new Node(new TextButton("moo5", skin));
tree.add(moo1);
tree.add(moo2);
moo2.add(moo3);
moo3.add(moo4);
tree.add(moo5);
moo5.getActor().addListener(new ClickListener() {
public void clicked (InputEvent event, float x, float y) {
tree.remove(moo4);
}
});
table.add(tree).fill().expand();
}
代码示例来源:origin: dingjibang/GDX-RPG
public TypedGdxQuery<T> listener(EventListener... listener){
for(EventListener l:listener)
t.addListener(l);
return this;
}
代码示例来源:origin: Var3D/var3dframe
public UI<T> addListener(EventListener listener) {
t.addListener(listener);
return this;
}
代码示例来源:origin: libgdx/libgdx
actor.setOrigin(50, 50);
stage.addActor(actor);
actor.addListener(new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
System.out.println("down");
代码示例来源:origin: com.badlogicgames.gdx/gdx
public boolean act (float delta) {
if (capture)
target.addCaptureListener(listener);
else
target.addListener(listener);
return true;
}
代码示例来源:origin: dingjibang/GDX-RPG
public GdxQuery listener(EventListener... listener){
for(Actor actor:list())
for(EventListener l:listener)
actor.addListener(l);
return this;
}
代码示例来源:origin: kotcrab/vis-ui
/**
* Attaches tooltip to current target, must be called if tooltip listener was removed from target (for example by
* calling target.clearListeners() )
*/
public void attach () {
if (target == null) return;
Array<EventListener> listeners = target.getListeners();
for (EventListener listener : listeners) {
if (listener instanceof TooltipInputListener) {
throw new IllegalStateException("More than one tooltip cannot be added to the same target!");
}
}
target.addListener(listener);
}
代码示例来源:origin: kotcrab/vis-ui
/**
* @param actor will have this listener attached and all other {@link Draggable} listeners removed. If you want multiple
* {@link Draggable} listeners or you are sure that the widget has no other {@link Draggable}s attached, you can add
* the listener using the standard method: {@link Actor#addListener(EventListener)} - avoiding validation and
* iteration over actor's listeners.
*/
public void attachTo (final Actor actor) {
for (final Iterator<EventListener> listeners = actor.getListeners().iterator(); listeners.hasNext(); ) {
final EventListener listener = listeners.next();
if (listener instanceof Draggable) {
listeners.remove();
}
}
actor.addListener(this);
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
public void setTarget (Actor newTarget) {
if (target != null) target.removeListener(listener);
super.setTarget(newTarget);
if (newTarget != null) newTarget.addListener(listener);
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
final ActorConsumer<?, Actor> action = parser.parseAction(rawAttributeData, actor);
if (action == null) {
parser.throwError("Could not find action for: " + rawAttributeData + " with actor: " + actor);
}
actor.addListener(new TimeThresholdChangeListener(0.5f) {
@Override
public void onChanged() {
action.consume(actor);
}
});
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
final ActorConsumer<?, Actor> action = parser.parseAction(rawAttributeData, actor);
if (action == null) {
parser.throwError("Could not find action for: " + rawAttributeData + " with actor: " + actor);
}
actor.addListener(new ClickListener() {
@Override
public void clicked(final InputEvent event, final float x, final float y) {
if (event.isCancelled() || event.getTarget() != actor) return;
action.consume(actor);
}
});
}
}
代码示例来源:origin: kotcrab/vis-ui
protected void prepareViewBeforeAddingToTable (ItemT item, ViewT view) {
boolean listenerMissing = true;
for (EventListener listener : view.getListeners()) {
if (listener instanceof AbstractListAdapter.ListClickListener) {
listenerMissing = false;
break;
}
}
if (listenerMissing) {
view.setTouchable(Touchable.enabled);
view.addListener(new ListClickListener(view, item));
}
}
代码示例来源:origin: dingjibang/GDX-RPG
private TypedGdxQuery<T> _tryRegListener() {
if(!t.getListeners().contains(clickListener(), true))
t.addListener(clickListener());
return this;
}
代码示例来源:origin: dingjibang/GDX-RPG
private GdxQuery _tryRegListener() {
for(Actor actor:list())
if(!actor.getListeners().contains(clickListener(), true))
actor.addListener(clickListener());
return this;
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
public static void setConsole(Console console) {
EditorLogger.console = console;
EditorLogger.console.setDisplayKeyID(Keys.F1);
console.setMaxEntries(1000);
final Stage s = (Stage) console.getInputProcessor();
final Actor actor = s.getActors().items[0];
actor.addListener(new InputListener() {
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
if (toActor == null) {
s.setScrollFocus(null);
}
}
});
console.setCommandExecutor(new EditorCommandExecutor());
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
private void showSuccessfulDialog(final FileHandle outputDir) {
VisDialog dialog = (VisDialog)interfaceService.getParser().parseTemplate(Gdx.files.internal("lml/textureunpacker/dialogSuccess.lml")).first();
dialog.findActor("btnOpenOutputDir").addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
try {
Desktop.getDesktop().open(outputDir.file());
} catch (IOException e) {
e.printStackTrace();
}
}
});
dialog.show(stage);
stage.setScrollFocus(dialog);
}
内容来源于网络,如有侵权,请联系作者删除!