diff --git a/core/src/com/saltosion/gladiator/GladiatorBrawler.java b/core/src/com/saltosion/gladiator/GladiatorBrawler.java index 8f189ab..70b900b 100644 --- a/core/src/com/saltosion/gladiator/GladiatorBrawler.java +++ b/core/src/com/saltosion/gladiator/GladiatorBrawler.java @@ -98,8 +98,6 @@ public class GladiatorBrawler extends ApplicationAdapter { box.dispose(); - - player = new Entity(); CRenderedObject renderedObject = new CRenderedObject(); @@ -110,7 +108,7 @@ public class GladiatorBrawler extends ApplicationAdapter { renderedObject.setCurrentSequence("Idle"); player.add(renderedObject); player.add(new CPhysics()); - player.getComponent(CPhysics.class).position.set(body.getPosition()); + player.getComponent(CPhysics.class).body = body; engine.addEntity(player); } diff --git a/core/src/com/saltosion/gladiator/components/CPhysics.java b/core/src/com/saltosion/gladiator/components/CPhysics.java index b4934ee..aff27f6 100644 --- a/core/src/com/saltosion/gladiator/components/CPhysics.java +++ b/core/src/com/saltosion/gladiator/components/CPhysics.java @@ -2,10 +2,11 @@ package com.saltosion.gladiator.components; import com.badlogic.ashley.core.Component; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.physics.box2d.Body; public class CPhysics extends Component { - public Vector2 position = new Vector2(0, 0); + public Body body; public Vector2 velocity = new Vector2(0, 0); } diff --git a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java index 8facffc..2975a93 100644 --- a/core/src/com/saltosion/gladiator/systems/RenderingSystem.java +++ b/core/src/com/saltosion/gladiator/systems/RenderingSystem.java @@ -69,7 +69,9 @@ public class RenderingSystem extends EntitySystem { int spriteHeight = currSprite.getRegionHeight(); int spriteWidth = currSprite.getRegionWidth(); - currSprite.setPosition(physics.position.x-spriteWidth/2, physics.position.y-spriteHeight/2); + currSprite.setPosition(physics.body.getPosition().x-spriteWidth/2, + physics.body.getPosition().y-spriteHeight/2); + currSprite.setRotation(physics.body.getAngle()); currSprite.draw(batch); float nextFrame = renderedObject.getCurrentFrame() + deltaTime*currSequence.getPlayspeed();