List of usage examples for com.badlogic.gdx.graphics.g2d PolygonSpriteBatch PolygonSpriteBatch
public PolygonSpriteBatch()
From source file:com.esotericsoftware.spine.Sandbox.java
License:Open Source License
public void create() { camera = new OrthographicCamera(); camera.setToOrtho(Y_DOWN);// w w w. j a v a 2 s. co m batch = new PolygonSpriteBatch(); renderer = new SkeletonMeshRenderer(); renderer.setPremultipliedAlpha(false); debugRenderer = new SkeletonRendererDebug(); debugRenderer.setBoundingBoxes(false); debugRenderer.setRegionAttachments(false); atlas = new TextureAtlas(Gdx.files.internal(ATLAS)); SkeletonJson json = new SkeletonJson(atlas); json.setScale(scale); SkeletonData skeletonData = json.readSkeletonData(Gdx.files.internal(JSON)); skeleton = new Skeleton(skeletonData); skeleton.setFlipY(Y_DOWN); skeleton.setPosition(X, Y); AnimationStateData stateData = new AnimationStateData(skeletonData); state = new AnimationState(stateData); if (ANIMATION != null) state.setAnimation(0, ANIMATION, true); if (ANIMATION_OFFSET != 0) { state.update(ANIMATION_OFFSET); state.apply(skeleton); skeleton.updateWorldTransform(); } }
From source file:com.esotericsoftware.spine.SimpleTest3.java
License:Open Source License
public void create() { camera = new OrthographicCamera(); batch = new PolygonSpriteBatch(); // Required to render meshes. SpriteBatch can't render meshes. renderer = new SkeletonRenderer(); renderer.setPremultipliedAlpha(true); debugRenderer = new SkeletonRendererDebug(); debugRenderer.setMeshTriangles(false); debugRenderer.setRegionAttachments(false); debugRenderer.setMeshHull(false);/*from ww w. j a va 2 s . c o m*/ atlas = new TextureAtlas(Gdx.files.internal("raptor/raptor.atlas")); SkeletonJson json = new SkeletonJson(atlas); // This loads skeleton JSON data, which is stateless. json.setScale(0.5f); // Load the skeleton at 50% the size it was in Spine. SkeletonData skeletonData = json.readSkeletonData(Gdx.files.internal("raptor/raptor.json")); skeleton = new Skeleton(skeletonData); // Skeleton holds skeleton state (bone positions, slot attachments, etc). skeleton.setPosition(250, 20); AnimationStateData stateData = new AnimationStateData(skeletonData); // Defines mixing (crossfading) between animations. state = new AnimationState(stateData); // Holds the animation state for a skeleton (current animation, time, etc). state.setTimeScale(0.6f); // Slow all animations down to 60% speed. // Queue animations on tracks 0 and 1. state.setAnimation(0, "walk", true); state.setAnimation(1, "empty", false); state.addAnimation(1, "gungrab", false, 2); // Keys in higher tracks override the pose from lower tracks. }
From source file:com.esotericsoftware.spine.SkeletonViewer.java
License:Open Source License
public void create() { ui = new UI(); batch = new PolygonSpriteBatch(); renderer = new SkeletonRenderer(); debugRenderer = new SkeletonRendererDebug(); skeletonX = (int) (ui.window.getWidth() + (Gdx.graphics.getWidth() - ui.window.getWidth()) / 2); skeletonY = Gdx.graphics.getHeight() / 4; loadSkeleton(Gdx.files.internal(/*ww w .ja v a 2 s.co m*/ Gdx.app.getPreferences("spine-skeletontest").getString("lastFile", "spineboy/spineboy.json")), false); }
From source file:com.kotcrab.vis.editor.Editor.java
License:Apache License
@Override public void create() { instance = this; Log.debug("Starting loading"); try {//from ww w. j a va 2 s . c o m GLFWIconSetter.newInstance().setIcon(Gdx.files.absolute(App.APP_FOLDER_PATH).child("cache/iconCache"), Gdx.files.internal("icon.ico"), Gdx.files.internal("icon.png")); } catch (IllegalStateException e) { Log.exception(e); } Assets.load(); VisUI.load(); VisUI.setDefaultTitleAlign(Align.center); Log.debug("VisUI " + VisUI.VERSION + " loaded"); polygonSpriteBatch = new PolygonSpriteBatch(); stage = createStage(); Gdx.input.setInputProcessor(stage); uiRoot = new VisTable(); uiRoot.setFillParent(true); stage.addActor(uiRoot); createUI(); createModuleContainers(); createModulesUI(); Log.debug("Loading completed"); if (experimentalSettings.isUIScale() || launchConfig.scaleUIEnabled) { stageViewport.setUnitsPerPixel(0.5f); } }
From source file:dk.gruppeseks.bodtrd.engine.Game.java
@Override public void create() { _pix = new Pixmap(1, 1, Pixmap.Format.RGBA8888); // Creates a pixel map with height and width of 1 pixel. RGBA8888 = 8 bit per color and alpha (32bit color system). _pix.setColor(1, 0.3f, 0.1f, 0.3f); // Red Green Blue Alpha. 1,1,1,1 would be white. 0,0,0,1 would be black. _pix.fill();/* w w w . j a va 2 s. c om*/ _textureSolid = new Texture(_pix); // A texture of one pixel (With a specific color) _textureRegion = new TextureRegion(_textureSolid); // A texture region keeps repeating a texture. _polyBatch = new PolygonSpriteBatch(); _font = new BitmapFont(); _shapeRenderer = new ShapeRenderer(); _batch = new SpriteBatch(); AssetsJarFileResolver jfhr = new AssetsJarFileResolver(); _assetManager = new AssetManager(jfhr); GameData gameData = new GameData(); _world = new World(gameData); gameData.setDisplayWidth(Gdx.graphics.getWidth()); gameData.setDisplayHeight(Gdx.graphics.getHeight()); _gameCamera = new OrthographicCamera(gameData.getDisplayWidth(), gameData.getDisplayHeight()); _hudCamera = new OrthographicCamera(gameData.getDisplayWidth(), gameData.getDisplayHeight()); _hudCamera.translate(gameData.getDisplayWidth() / 2, gameData.getDisplayHeight() / 2); _hudCamera.update(); _mapResult = _lookup.lookupResult(MapSPI.class); _mapResult.addLookupListener(mapLookupListener); _map = _lookup.lookup(MapSPI.class); _map.generateMap(_world); Gdx.input.setInputProcessor(new GameInputManager()); _result = _lookup.lookupResult(GamePluginSPI.class); _result.addLookupListener(lookupListener); _gamePlugins.addAll(_result.allInstances()); for (GamePluginSPI plugin : _gamePlugins) { plugin.start(_world); } BACKGROUND_MUSIC_TOTAL_FILE_PATH = Game.class.getResource(BACKGROUND_MUSIC_FILE_PATH).getPath() .replace("file:", ""); AudioManager.createSound(BACKGROUND_MUSIC_TOTAL_FILE_PATH, AudioType.MUSIC); loadViews(); loadAudio(); _assetManager.finishLoading(); AudioManager.playSound(BACKGROUND_MUSIC_TOTAL_FILE_PATH, AudioAction.LOOP); }
From source file:es.eucm.ead.editor.utils.TexturedShapeEditor.java
License:Open Source License
@Override public void create() { super.create(); executor = new AsyncExecutor(1); // create a string of generally-overlapping polygons, will draw in // blue//from w w w. j ava 2s .com GeoTester.randomPolys(3, 40, 80, new Vector2(100, 300), blue); float s = 10; Polygon p0 = new Polygon(new float[] { // north-west, low, north-east 0, 3 * s, 0, 2 * s, 2 * s, 0, 3 * s, 0, 4.5f * s, 2 * s, 6 * s, 0, 7 * s, 0, 9 * s, 2 * s, 9 * s, 3 * s, // north-east, high, north-west 8 * s, 3 * s, 6.5f * s, 1 * s, 5 * s, 3 * s, 4 * s, 3 * s, 2.5f * s, s, 1 * s, 3 * s }); blue.add(p0); // merge them into a single polygon, will draw in red for (Polygon bp : blue) { GeometryUtils.merge(geo, bp); } Geometry collapsed = GeometryUtils.collapse(geo); Polygon p = GeometryUtils.jtsCoordsToGdx(collapsed.getCoordinates()); red.add(p); triangles = GeometryUtils.triangulate(collapsed); Gdx.app.error("GeoTester", "ready to display triangles worth " + triangles.length + " vertices"); // use the polygon to clip a randomly-generated texture textureSolid = new Texture(GeoTester.randomPixmap(100, 100, null), false); PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid), p.getVertices(), triangles); poly = new PolygonSprite(polyReg); poly.setOrigin(p.getVertices()[0], p.getVertices()[1]); polyBatch = new PolygonSpriteBatch(); // prepare rendering aids shapeRenderer = new ShapeRenderer(); Gdx.input.setInputProcessor(this); }
From source file:es.eucm.ead.engine.EngineApplicationListener.java
License:Open Source License
/** * Creates a Stage as in {@link Stage#Stage()}, but using * {@link PolygonSpriteBatch} instead of {@link SpriteBatch} * // w w w .j a va2 s . c o m * PolygonSpriteBatch must be used for * {@link es.eucm.ead.engine.components.renderers.SpineAnimationComponent} * to work properly. */ protected Stage createStage() { Viewport viewport = new ScalingViewport(Scaling.stretch, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), new OrthographicCamera()); PolygonSpriteBatch batch = new PolygonSpriteBatch(); Stage newStage = new Stage(viewport, batch); return newStage; }