Jump to content

Search the Community

Showing results for tags 'Box2D libGdx'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Spriter General
    • Spriter
    • Help and Tutorials
  • Art Packs
    • Spriter Animated Art Packs
  • Developers
    • Spriter Implementations
    • Developer Help
  • General
    • Open Topic
    • Your Works
  • Jobs, Freelance, and Collaboration
    • Portfolios
    • Job offers (Paid)

Product Groups

  • Software
  • Animated Art Packs
  • Bundles
  • Environment Art Packs
  • 3D Art Packs

Categories

  • Software
    • 3rd Party Productivity Software
  • Paid Spriter Animations
    • Paid Spriter Art Pack Skins
  • Paid Environment Art
  • Free Spriter Animations
    • Free Art Pack Skins
  • Free Environment Art
  • 3D Art for games

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. 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...