Note that there are some explanatory texts on larger screens.

plurals
  1. POMoving a point (vector) on an angle + Libgdx
    primarykey
    data
    text
    <p>i wanna move a point (Vector2) on an angle. i have my angle. but i'm not good in math or libgdx. for getting angle i use this : </p> <pre><code>degrees = (float) ((Math.atan2(touchPoint.x - x, -(touchPoint.y - y)) * 180.0d / Math.PI) + 240.0f); </code></pre> <p>now, i want to move vector. but i really don't know what i must do... i looked at questions but there was just somethings about changing angle, not transfer. i think there must be a function for this in libgdx. please help.</p> <p>UPDATE :</p> <pre><code>public class Games implements ApplicationListener { SpriteBatch spriteBatch; Texture texture; float x = 160; float y = 5; Vector2 touch; Vector2 movement; Vector2 position; Vector2 dir; Vector2 velocity; float speed; float deltaTime; @Override public void create() { spriteBatch = new SpriteBatch(); texture = new Texture(Gdx.files.internal("images/1.png")); touch = new Vector2(); movement = new Vector2(); position = new Vector2(); dir = new Vector2(); velocity = new Vector2(); speed = 5; deltaTime = Gdx.graphics.getDeltaTime(); } public void render() { Gdx.gl.glClear(Gdx.gl10.GL_COLOR_BUFFER_BIT); deltaTime += 0.5f; spriteBatch.begin(); begin(deltaTime); spriteBatch.draw(texture, position.x, position.y); spriteBatch.end(); } private void begin(float deltaTime) { touch.set(Gdx.input.getX(), Gdx.input.getY()); position.set(x, y); dir.set(touch).sub(position).nor(); velocity.set(dir).scl(speed); movement.set(velocity).scl(deltaTime); position.add(movement); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload