1

我有一个正在编译为 HTML5 的 PlayN 游戏。我使用普通的 DOM 元素在 GWT 中构建了一个 UI。这个 UI 承载了渲染游戏的画布。

给定一个描述图像位置的字符串,我想使用 PlayN 的客户端包来查找图像。目前,HtmlAssetManager 有一个类似的功能:

  @Override
  protected Image loadImage(String path) {
    String url = pathPrefix + path;

    AutoClientBundleWithLookup clientBundle = getBundle(path);
    if (clientBundle != null) {
      String key = getKey(path);
      ImageResource resource = (ImageResource) getResource(key, clientBundle);
      if (resource != null) {
        url = resource.getURL();
      }
    }

    return adaptImage(url);
  }

我只想要 url,所以我可以构造一个Image小部件:

  @Override
  protected String loadImage(String path) {
    String url = pathPrefix + path;

    AutoClientBundleWithLookup clientBundle = getBundle(path);
    if (clientBundle != null) {
      String key = getKey(path);
      ImageResource resource = (ImageResource) getResource(key, clientBundle);
      if (resource != null) {
        url = resource.getURL();
      }
    }

    return url;
  }

有什么方法可以从我的 GWT UI 代码中访问它吗?我想我可以分叉 PlayN 和 subclass HtmlAssetManager,然后PlayN.assetManager()转换为HtmlAssetManager,但我宁愿不这样做。

4

0 回答 0