public static TextureRegion CreateFromSource(BuildableTexture pBuildableTexture, ITextureSource pTextureSource) { TextureRegion textureRegion = new TextureRegion(pBuildableTexture, 0, 0, pTextureSource.GetWidth(), pTextureSource.GetHeight()); TextureSourceWithLocationCallback callback = new TextureSourceWithLocationCallback(textureRegion); pBuildableTexture.AddTextureSource(pTextureSource, callback); return(textureRegion); }
/* * public static TiledTextureRegion createTiledFromSource(final BuildableTexture pBuildableTexture, final ITextureSource pTextureSource, final int pTileColumns, final int pTileRows) { * final TiledTextureRegion tiledTextureRegion = new TiledTextureRegion(pBuildableTexture, 0, 0, pTextureSource.getWidth(), pTextureSource.getHeight(), pTileColumns, pTileRows); * pBuildableTexture.addTextureSource(pTextureSource, new Callback<TextureSourceWithLocation>() { * @Override * public void onCallback(final TextureSourceWithLocation pCallbackValue) { * tiledTextureRegion.setTexturePosition(pCallbackValue.getTexturePositionX(), pCallbackValue.getTexturePositionY()); * } * }); * return tiledTextureRegion; * } */ public static TiledTextureRegion CreateTiledFromSource(BuildableTexture pBuildableTexture, ITextureSource pTextureSource, int pTileColumns, int pTileRows) { //TiledTextureRegion tiledTextureRegion = new TiledTextureRegion(pBuildableTexture, 0, 0, pTextureSource.getWidth(), pTextureSource.getHeight(), pTileColumns, pTileRows); TiledTextureRegion tiledTextureRegion = new TiledTextureRegion(pBuildableTexture, 0, 0, pTextureSource.GetWidth(), pTextureSource.GetHeight(), pTileColumns, pTileRows); pBuildableTexture.AddTextureSource(pTextureSource, new TextureSourceWithLocationCallback(tiledTextureRegion)); return(tiledTextureRegion); }
// =========================================================== // Getter & Setter // =========================================================== // =========================================================== // Methods for/from SuperClass/Interfaces // =========================================================== //@SuppressWarnings("deprecation") //@Override //public override void pack(final BuildableTexture pBuildableTexture, final ArrayList<TextureSourceWithWithLocationCallback> pTextureSourcesWithLocationCallback) throws IllegalArgumentException { public /* override */ void Pack(BuildableTexture pBuildableTexture, List <TextureSourceWithLocationCallback> pTextureSourcesWithLocationCallback) { //Collections.sort(pTextureSourcesWithLocationCallback, TEXTURESOURCE_COMPARATOR); pTextureSourcesWithLocationCallback.Sort((IComparer <TextureSourceWithLocationCallback>)TEXTURESOURCE_COMPARER); NodeClass root = new NodeClass(new RectClass(0, 0, pBuildableTexture.GetWidth(), pBuildableTexture.GetHeight())); int textureSourceCount = pTextureSourcesWithLocationCallback.Count; for (int i = 0; i < textureSourceCount; i++) { TextureSourceWithLocationCallback textureSourceWithLocationCallback = pTextureSourcesWithLocationCallback[i]; ITextureSource textureSource = textureSourceWithLocationCallback.GetTextureSource(); NodeClass inserted = root.Insert(textureSource, pBuildableTexture.GetWidth(), pBuildableTexture.GetHeight(), this.mTextureSourceSpacing); if (inserted == null) { throw new IllegalArgumentException("Could not pack: " + textureSource.ToString()); } TextureSourceWithLocation textureSourceWithLocation = pBuildableTexture.AddTextureSource(textureSource, inserted.mRect.mLeft, inserted.mRect.mTop); textureSourceWithLocationCallback.GetCallback().OnCallback(textureSourceWithLocation); } }