com.badlogic.gdx.scenes.scene2d.Actor.getUserObject()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中com.badlogic.gdx.scenes.scene2d.Actor.getUserObject()方法的一些代码示例,展示了Actor.getUserObject()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Actor.getUserObject()方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Actor
类名称:Actor
方法名:getUserObject

Actor.getUserObject介绍

[英]Returns an application specific object for convenience, or null.
[中]为方便起见,返回特定于应用程序的对象,或为null。

代码示例

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

public ViewHolder getViewHolder(Actor view) {
  return (ViewHolder) view.getUserObject();
}

代码示例来源:origin: dingjibang/GDX-RPG

public Object userObject(){
  return t.getUserObject();
}

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

public ViewHolder getViewHolder(Actor view) {
  ViewHolder viewHolder = (ViewHolder) view.getUserObject();
  if (viewHolder == null) {
    throw new IllegalArgumentException("View has no associated ViewHolder. Probably it's not in adapter yet. View: " + view);
  }
  return viewHolder;
}

代码示例来源:origin: peakgames/libgdx-stagebuilder

/**
 * Actor'un list adapter'daki sirasini doner.
 *
 * @param actor
 * @return actor index.
 */
private int getActorIndex(Actor actor) {
  Object userObject = actor.getUserObject();
  if (userObject == null) {
    throw new RuntimeException("Actor " + actor + " does not have a userObject");
  }
  return (Integer) userObject;
}

代码示例来源:origin: peakgames/libgdx-stagebuilder

public Actor getActorWithUserObject(int index) {
  SnapshotArray<Actor> children = getChildren();
  int count = children.size;
  for (int i = 0; i < count; i++) {
    Actor child = children.get(i);
    if (child.getUserObject() != null && index == (Integer)child.getUserObject()) {
      return child;
    }
  }
  return EMPTY_ACTOR;
}

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

@Override
  public void clicked(InputEvent event, float x, float y) {
    int i = (Integer) event.getListenerActor().getUserObject();
    select(i);
  }
});

代码示例来源:origin: dingjibang/GDX-RPG

public Object userObject(){
  return get().getUserObject();
}

代码示例来源:origin: dingjibang/GDX-RPG

public Object object(){
  return cell.getActor().getUserObject();
}

代码示例来源:origin: dingjibang/GDX-RPG

public GdxQuery findUserObjectInstanceOf(Class<?>... clz){
  GdxQuery result = $.add().father(this);
  
  for(Class<?> c:clz)
    for(Actor actor:list())
      if(actor.getUserObject()!=null && (actor.getUserObject().getClass().equals(c) || actor.getUserObject().getClass().getSuperclass().equals(c)))
        result.add(actor);
  
  return result;
}

代码示例来源:origin: dingjibang/GDX-RPG

public GdxQuery notUserObject(Object userObject){
  for(Actor actor:list())
    if(!(actor.getUserObject()!=null && actor.getUserObject().equals(userObject)))
      return $.add(actor);
  return $.add();
}

代码示例来源:origin: dingjibang/GDX-RPG

public GdxQuery find(Object userObject){
  if(userObject instanceof Class)
    return find((Class<?>)userObject,null);
  
  GdxQuery result = $.add().father(this);
  
  for(Actor actor:list())
    if(actor.getUserObject()!=null && actor.getUserObject().equals(userObject))
      result.add(actor);
  
  return result;
}

代码示例来源:origin: peakgames/libgdx-stagebuilder

@Override
  public boolean longPress(Actor actor, float x, float y) {
    int position = (Integer) actor.getUserObject();
    if (onItemLongPressedListener != null && state == ListWidgetState.STEADY) {
      onItemLongPressedListener.onItemLongPressed(listAdapter.getItem(position), actor, position);
    }
    return super.longPress(actor, x, y);
  }
};

代码示例来源:origin: peakgames/libgdx-stagebuilder

@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
  super.tap(event, x, y, count, button);
  Actor actor = event.getListenerActor();
  int position = (Integer) actor.getUserObject();
  if (onItemClickedListener != null ) {
    onItemClickedListener.onItemClicked(listAdapter.getItem(position), actor, position);
  }
}

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

public void clicked(InputEvent event, float x, float y) {
    int i = (Integer) event.getListenerActor().getUserObject();
    Inventory inv = sceneScreen.getUI().getWorld().getInventory();
    target = null;
    if (i < inv.getNumItems()) {
      InteractiveActor actor = inv.get(i);
      if (currentVerb.equals("use") || currentVerb.equals("give")) {
        target = actor;
      } else {
        sceneScreen.runVerb(actor, currentVerb, null);
      }
    }
  }
});

代码示例来源:origin: peakgames/libgdx-stagebuilder

private void settleIfNecessary() {
  if (!listAdapter.isEmpty()) {
    Actor tailActor = getTailActor();
    if (isLastActor(tailActor)) {
      Actor headActor = getHeadActor();
      if (headActor.getUserObject().equals(0) && (isVertical || getActorPos(headActor) >= headPadding)) {
        state = ListWidgetState.SETTLE_HEAD;
        clearAndInitActorList(0);
      } else if (isVertical ? getActorPos(tailActor) > 0 : getActorOrigin(tailActor) < measure) {
        state = ListWidgetState.SETTLE_TAIL;
        clearAndInitActorList(((Integer) headActor.getUserObject()) - 1);
      }
    }
  }
}

代码示例来源:origin: peakgames/libgdx-stagebuilder

public boolean replaceChildWith(Actor actorToRemove, Actor actorToInsert) {
    int index = getChildren().indexOf(actorToRemove, false);
    if (index == -1) return false;
    
    actorToInsert.setPosition(actorToRemove.getX(), actorToRemove.getY());
    actorToInsert.setUserObject(actorToRemove.getUserObject());
    removeActor(actorToRemove, false);
    addActorAt(index, actorToInsert);
    
    return true;
  }
}

代码示例来源:origin: peakgames/libgdx-stagebuilder

@Override
public void act(float delta) {
  super.act(delta);
  if (needsLayout) {
    if (state != ListWidgetState.STEADY) {
      handleState(delta);
      return;
    }
    
    int headActorIndex = 0;
    if(hasChildren()) {
      Actor headActor = getHeadActor();
      headActorIndex = (Integer)headActor.getUserObject();
    }
    if(resetPosition) {
      clearAndInitActorList(headActorIndex);
    } else {
      resetActorsData(headActorIndex);
    }
    settleIfNecessary();
    needsLayout = false;
  }
  handleState(delta);
}

相关文章