@@ 27,7 27,7 @@ import com.badlogic.gdx.scenes.scene2d.u
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pools;
import net.dermetfan.gdx.scenes.scene2d.Scene2DUtils;
-import net.dermetfan.jigsawPuzzle.utils.PolygonRegionDrawable;
+import net.dermetfan.gdx.scenes.scene2d.utils.PolygonRegionDrawable;
/** represents a puzzle and manages {@link Piece Pieces}
* @author dermetfan */
@@ 28,12 28,12 @@ import com.badlogic.gdx.scenes.scene2d.u
import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
import com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
+import net.dermetfan.gdx.scenes.scene2d.utils.PolygonRegionDrawable;
import net.dermetfan.jigsawPuzzle.Assets;
import net.dermetfan.jigsawPuzzle.puzzle.JigsawPuzzle;
import net.dermetfan.jigsawPuzzle.puzzle.JigsawPuzzle.Piece;
import net.dermetfan.jigsawPuzzle.puzzle.JigsawPuzzle.Source;
import net.dermetfan.jigsawPuzzle.puzzle.JigsawPuzzle.Target;
-import net.dermetfan.jigsawPuzzle.utils.PolygonRegionDrawable;
/** a UI for a {@link JigsawPuzzle}
* @author dermetfan */
@@ 43,7 43,7 @@ public class PlayScreen extends ScreenAd
private Stage stage;
public PlayScreen() {
- stage = new Stage(new ScreenViewport(), batch); // make the stage use the batch (by default, it creates a SpriteBatch, but we need a PolygonSpriteBatch
+ stage = new Stage(new ScreenViewport(), batch); // make the stage use the batch (by default, it creates a SpriteBatch, but we need a PolygonSpriteBatch)
stage.setDebugAll(true);
Gdx.input.getTextInput(new TextInputListener() { // temporary solution - ask user for name of the level directory to load psh files (pieces) from
@Override
@@ 1,112 0,0 @@
-/** Copyright 2014 Robin Stumm (serverkorken@gmail.com, http://dermetfan.net)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. */
-
-package net.dermetfan.jigsawPuzzle.utils;
-
-import com.badlogic.gdx.graphics.g2d.Batch;
-import com.badlogic.gdx.graphics.g2d.PolygonRegion;
-import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
-import com.badlogic.gdx.scenes.scene2d.utils.BaseDrawable;
-import com.badlogic.gdx.scenes.scene2d.utils.TransformDrawable;
-import net.dermetfan.utils.math.GeometryUtils;
-
-/** Drawable for a {@link PolygonRegion}.
- * @author dermetfan */
-public class PolygonRegionDrawable extends BaseDrawable implements TransformDrawable {
-
- /** the region to draw */
- private PolygonRegion region;
-
- /** the min x and y values of the vertices of {@link #region} */
- private float polygonX, polygonY;
-
- /** the size of the vertices of {@link #region} */
- private float polygonWidth, polygonHeight;
-
- /** Creates an uninitialized instance. The region must be {@link #setRegion(PolygonRegion) set} before use. */
- public PolygonRegionDrawable() {}
-
- /** @param region the region to use */
- public PolygonRegionDrawable(PolygonRegion region) {
- setRegion(region);
- }
-
- /** @param drawable the drawable to copy */
- public PolygonRegionDrawable(PolygonRegionDrawable drawable) {
- super(drawable);
- this.region = drawable.region;
- this.polygonX = drawable.polygonX;
- this.polygonY = drawable.polygonY;
- this.polygonWidth = drawable.polygonWidth;
- this.polygonHeight = drawable.polygonHeight;
- }
-
- @Override
- public void draw(Batch batch, float x, float y, float width, float height) {
- width += region.getRegion().getRegionWidth() - polygonWidth;
- height += region.getRegion().getRegionHeight() - polygonHeight;
- if(batch instanceof PolygonSpriteBatch)
- ((PolygonSpriteBatch) batch).draw(region, x - polygonX, y - polygonY, width, height);
- else
- batch.draw(region.getRegion(), x, y, width, height);
- }
-
- @Override
- public void draw(Batch batch, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation) {
- width += region.getRegion().getRegionWidth() - polygonWidth;
- height += region.getRegion().getRegionHeight() - polygonHeight;
- if(batch instanceof PolygonSpriteBatch)
- ((PolygonSpriteBatch) batch).draw(region, x - polygonX, y - polygonY, originX, originY, width, height, scaleX, scaleY, rotation);
- else
- batch.draw(region.getRegion(), x, y, originX, originY, width, height, scaleX, scaleY, rotation);
- }
-
- /** @param region the {@link #region} to set */
- public void setRegion(PolygonRegion region) {
- this.region = region;
- float[] vertices = region.getVertices();
- polygonWidth = GeometryUtils.width(vertices);
- polygonHeight = GeometryUtils.height(vertices);
- polygonX = GeometryUtils.minX(vertices);
- polygonY = GeometryUtils.minY(vertices);
- setMinWidth(polygonWidth);
- setMinHeight(polygonHeight);
- }
-
- /** @return the {@link #region} */
- public PolygonRegion getRegion() {
- return region;
- }
-
- /** @return the {@link #polygonX} */
- public float getPolygonX() {
- return polygonX;
- }
-
- /** @return the {@link #polygonY} */
- public float getPolygonY() {
- return polygonY;
- }
-
- /** @return the {@link #polygonWidth} */
- public float getPolygonWidth() {
- return polygonWidth;
- }
-
- /** @return the {@link #polygonHeight} */
- public float getPolygonHeight() {
- return polygonHeight;
- }
-
-}