Jump to content

systemExklusiv

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by systemExklusiv

  1. Replying to my own post. I was not clearly thinking yesterday. The java.io.File was not causing the error but com.badlogic.gdx.backends.GWTFileHandle had in this extension of the FileHandle-class a not working implementation of the file()-Method. /** Returns a java.io.File that represents this file handle. Note the returned file will only be usable for {@link FileType#Absolute} and {@link FileType#External} file handles. */public File file () { throw new GdxRuntimeException("Not supported in GWT backend"); } I guess that is ok because all resources are loaded from the war/assets folder. In my first post, the line which caused the error used the unsupported method above. The loader of trixt0r's runtime needs the File from the Gdx's FileHandle in oder to get to the parent-folder (in order to iterate on the spriter related data). The quick solution in my case is to use load-method with the String-param, suplied by the com.brashmonkey.spriter.Loader<R> class which has #load(String root). The libGdx-loader class extends from this. If I get this alltogether working and compiling to all targets i'll try to put a preconfigured project somewhere.
  2. Hi everyone! My main question: has anyone experience in crosscompiling the runtime to JS by GWT with gradle? I have a class, SpriterScreen, which I pasted below. In the class I put more/less the content of one of trixt0r's testclasses,com.brashmonkey.spriter.tests.backend.LibGdxTest, for the libGdx runtime. I had refactor it to fit in a Screen. When I want to crosscompile this class with GWT by the gradle-Task gradlew html:sperdev I get compiler errors. I copied them below the origination class. package net.systemexklusive.site.app.screens;import com.badlogic.gdx.Gdx;import com.badlogic.gdx.Screen;import com.badlogic.gdx.files.FileHandle;import com.badlogic.gdx.graphics.GL20;import com.badlogic.gdx.graphics.OrthographicCamera;import com.badlogic.gdx.graphics.g2d.Sprite;import com.badlogic.gdx.graphics.g2d.SpriteBatch;import com.badlogic.gdx.graphics.glutils.ShapeRenderer;import com.brashmonkey.spriter.Data;import com.brashmonkey.spriter.Drawer;import com.brashmonkey.spriter.Player;import com.brashmonkey.spriter.SCMLReader;import com.brashmonkey.spriter.libGdx.LibGdxDrawer;import com.brashmonkey.spriter.libGdx.LibGdxLoader;import net.systemexklusive.site.SysExApp;/* Error is in the show-method */public class SpriterScreen implements Screen {Player player;ShapeRenderer renderer;SpriteBatch batch;Drawer<Sprite> drawer;LibGdxLoader loader;OrthographicCamera cam;@Overridepublic void show() {cam = new OrthographicCamera();cam.zoom = 1f;renderer = new ShapeRenderer();batch = new SpriteBatch();FileHandle handle = Gdx.files.internal("monster/basic_002.scml");Data data = new SCMLReader(handle.read()).getData();loader = new LibGdxLoader(data);/* ---- The line below is responsible for the crosscompiler Error --- */loader.load(handle.file());drawer = new LibGdxDrawer(loader, batch, renderer);player = new Player(data.getEntity(0));}@Overridepublic void render(float delta) {}@Overridepublic void resize(int width, int height) {cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());cam.position.set(0, 0, 0f);cam.update();renderer.setProjectionMatrix(cam.combined);batch.setProjectionMatrix(cam.combined);}@Overridepublic void pause() {}@Overridepublic void resume() {}@Overridepublic void hide() {}@Overridepublic void dispose() {renderer.dispose();loader.dispose();}} Here is a snippet of the console out triggered by 'gradlew html:superDev' 17:25:28.124 [QUIET] [system.out] Compiling module net.systemexklusive.site.GdxDefinitionSuperdev17:25:30.789 [QUIET] [system.out] Validating units:17:25:30.790 [QUIET] [system.out] Ignored 2 units with compilation errors in first pass.Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.17:25:32.755 [QUIET] [system.out] D:\coding\libGdx\IdeaProjects\SysExSiteGame\html\.17:25:32.755 [QUIET] [system.out] ../android/assets17:25:32.758 [QUIET] [system.out] Copying resources from ../android/assets to war/17:25:32.759 [QUIET] [system.out] D:\coding\libGdx\IdeaProjects\SysExSiteGame\html\..\android\assets17:25:32.759 [QUIET] [system.out] D:\coding\libGdx\IdeaProjects\SysExSiteGame\html\assets17:25:33.149 [QUIET] [system.out] [ERROR] Errors in 'file:/D:/coding/libGdx/IdeaProjects/SysExSiteGame/core/src/net/systemexklusive/site/app/screens/SpriterScreen.java'17:25:33.150 [QUIET] [system.out] [ERROR] Line 56: The method file() is undefined for the type FileHandle17:25:33.155 [QUIET] [system.out] Computing all possible rebind results for 'com.badlogic.gwtref.client.IReflectionCache'17:25:33.155 [QUIET] [system.out] Rebinding com.badlogic.gwtref.client.IReflectionCache17:25:33.156 [QUIET] [system.out] Invoking generator com.badlogic.gwtref.gen.ReflectionCacheGenerator17:25:33.157 [QUIET] [system.out] com.badlogic.gwtref.client.IReflectionCache17:25:33.651 [QUIET] [system.out] java.lang.Double17:25:33.652 [QUIET] [system.out] double Somehow it complains that the FileHandle has no file()-Method. But as I understand, the runtime and the libGdx-Type are about the java.io.File. I put the runtime sources in the core-module and expanded the xxx.gwt.xml. Can anyone give me some hints? This would be great because I struggling with this build for quite a while now and I'd really like to see the anims on a browser! Thank you
  3. Oh man, sorry for the delay! Thanks form the answer! Yeah, your idea encompasses some really complicated 'force-applying' to simulate e.g. a walking movement. One could go further this direction: create a body for each object and interconnect them with joints. update all bodies by the animation except one at the center, which position etc. will be calculated by the physics world. All the other bodies will driven by the animation, in a way that joints are adjusted. But this seems difficult to accomplish.
  4. Hello everyone! I'm pondering on how to let a Spriter's sprite take part in B2D physics world. First of all my general question: How would you do it? My thoughts so far: First of all I used the loader/drawer of trixt0r to get to ready setup libGdx Sprites conveniently. From tis point I tried to get them taking part in physics. a) My first idea was to make out of each object/box of an entity a static B2D-Body which get a rectangular shape. The rect-shape is just for simplicity - of course the don't yield perfect coillsion. These bodies get updated each frame when the Spriter animation renders to get new x,y and rotation. By doing this, the texture regions of the sprite are sync'ed with the body's fixture shape. It follows a screenshot of the Spriters monster-Sprite, where all the objects (trixt0r lib for libGdx) which have textures attached to have a green bounding box around them. These Boxes are also shapes attached to B2D-Bodies (as fixture shape). This works so far unless I want to apply force to the monster itself. The problem is that the animation itself is controlling the physics not vice versa. I 'd want to let the monster fall down, I would have to make these by translation the coordinates of the Sprite instead of letting the Word control the position e.g. when its no longer grounded because there is no body underneath - thus I'm loosing the a lot of the advantages of a physics sim. I pasted in some code for setting this up (the following iteration is based on the code of libGdxDrawer class of trixt0r except the b2d stuff) - just to get the idea. public static void setUpBodiesToWorld(Player player, Loader<SpriteBox2D> loader,World world) { Iterator<Timeline.Key.Object> it = player.objectIterator(); while(it.hasNext()){ // itereation over all the objects with a libGdx-Sprite Timeline.Key.Object object = it.next(); /* the loader is of tpe Loader<SpriteBox2d> - its like Sprite , I put just a public field for the body in it */ SpriteBox2D sprite = loader.get(object.ref); /*Setting up the fixture shape of the body - below is just an example for taking the objects-boxes a shapes for bodies */ PolygonShape box = new PolygonShape(); box.setAsBox(sprite.getWidth() / 2 * sprite.getScaleX() , sprite.getHeight() / 2 * sprite.getScaleY() , vector.set(sprite.getX(), sprite.getY()), sprite.getRotation() * MathUtils.degRad); BodyDef boxBodyDef = new BodyDef(); boxBodyDef.type = BodyDef.BodyType.StaticBody; Body body = world.createBody(boxBodyDef); /*assigning the body and making a association between the TextureRegion and the body When rendering the sprite, the body can be easily retrieved and positioned*/ sprite.body = body; Fixture fixture = body.createFixture(box, 1); fixture.setUserData(sprite); box.dispose(); } } When the libGdx-Drawer iterates over the Player and retrieves the Sprites an additional body can be retrieved and positioned. b > My second guess was to draw a static form around the sprite (like the orange ellipse in the screenshot) which encompasses roughly the sprite. This shape is the bodyshape in B2D and keeps track of the curren pos and rotation. The sprite positions accordingly to the shape - but with odd visual side effects - e.g. things which look like they should collide don't and vice versa. I believe the main problem is that the physics aren't involved animating the bones and its difficult to make them behave physically afterwards. What are your thoughts/Experiences? Thanks david
×
×
  • Create New...