public void paint(Clock clock) { if (!hasLoaded) return; // body.setLinearVelocity(new Vec2(30 * MathUtils.cos(GameScreen.angle), 30 * // MathUtils.sin(GameScreen.angle))); sprite .layer() .setTranslation( (body.getPosition().x / GameScreen.M_PER_PIXEL), (body.getPosition().y / GameScreen.M_PER_PIXEL)); Vec2 delta = new Vec2(80f - body.getPosition().x, 400f - body.getPosition().y); float angle = MathUtils.atan2(delta.x, delta.y); body.setLinearVelocity(new Vec2(8 * -MathUtils.cos(angle), 8 * MathUtils.sin(angle))); }
public final void synchronizeTransform() { // m_xf.R.set(m_sweep.a); // // //m_xf.position = m_sweep.c - Mul(m_xf.R, m_sweep.localCenter); // Mat22.mulToOut(m_xf.R, m_sweep.localCenter, m_xf.position); // m_xf.position.mulLocal(-1).addLocal(m_sweep.c); final float c = MathUtils.cos(m_sweep.a), s = MathUtils.sin(m_sweep.a); m_xf.R.m11 = c; m_xf.R.m21 = -s; m_xf.R.m12 = s; m_xf.R.m22 = c; m_xf.position.x = m_xf.R.m11 * m_sweep.localCenter.x + m_xf.R.m21 * m_sweep.localCenter.y; m_xf.position.y = m_xf.R.m12 * m_sweep.localCenter.x + m_xf.R.m22 * m_sweep.localCenter.y; m_xf.position.x *= -1f; m_xf.position.y *= -1f; m_xf.position.x += m_sweep.c.x; m_xf.position.y += m_sweep.c.y; }