本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.addTouchFocus()
方法的一些代码示例,展示了Stage.addTouchFocus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.addTouchFocus()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:addTouchFocus
[英]Adds the listener to be notified for all touchDragged and touchUp events for the specified pointer and button. Touch focus is added automatically when true is returned from InputListener#touchDown(InputEvent,float,float,int,int). The specified actors will be used as the Event#getListenerActor() and Event#getTarget() for the touchDragged and touchUp events.
[中]添加要为指定指针和按钮的所有触碰和触碰事件通知的侦听器。当InputListener#触地(InputEvent、float、float、int、int)返回true时,触摸焦点会自动添加。指定的参与者将用作TouchDrawed和touchUp事件的事件#GetListGenerator()和事件#getTarget()。
代码示例来源:origin: libgdx/libgdx
InputEvent inputEvent = (InputEvent)event;
if (inputEvent.getType() == Type.touchDown) {
event.getStage().addTouchFocus(listener, this, inputEvent.getTarget(), inputEvent.getPointer(),
inputEvent.getButton());
代码示例来源:origin: libgdx/libgdx
InputEvent inputEvent = (InputEvent)event;
if (inputEvent.getType() == Type.touchDown) {
event.getStage().addTouchFocus(listener, this, inputEvent.getTarget(), inputEvent.getPointer(),
inputEvent.getButton());
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Notifies this actor's listeners of the event. The event is not propagated to any parents. Before notifying the listeners,
* this actor is set as the {@link Event#getListenerActor() listener actor}. The event {@link Event#setTarget(Actor) target}
* must be set before calling this method. If this actor is not in the stage, the stage must be set before calling this method.
* @param capture If true, the capture listeners will be notified instead of the regular listeners.
* @return true of the event was {@link Event#cancel() cancelled}. */
public boolean notify (Event event, boolean capture) {
if (event.getTarget() == null) throw new IllegalArgumentException("The event target cannot be null.");
DelayedRemovalArray<EventListener> listeners = capture ? captureListeners : this.listeners;
if (listeners.size == 0) return event.isCancelled();
event.setListenerActor(this);
event.setCapture(capture);
if (event.getStage() == null) event.setStage(stage);
listeners.begin();
for (int i = 0, n = listeners.size; i < n; i++) {
EventListener listener = listeners.get(i);
if (listener.handle(event)) {
event.handle();
if (event instanceof InputEvent) {
InputEvent inputEvent = (InputEvent)event;
if (inputEvent.getType() == Type.touchDown) {
event.getStage().addTouchFocus(listener, this, inputEvent.getTarget(), inputEvent.getPointer(),
inputEvent.getButton());
}
}
}
}
listeners.end();
return event.isCancelled();
}
内容来源于网络,如有侵权,请联系作者删除!