Monday 15 September 2014

android - how to move character - trying to apply touchDown and touchUp -


Example I'm trying to use

  if (Gdx.input isTouched ( )) {Vector 3 TouchPos = new vector 3 (); Touch Posaset (Gdx.input.getX (), Gdx.input.getY (), 0);   

(); Vector 2 velocity = new vector 2 ();

and then:

  public boolean touchdown (int x, int y, int pointer, int button) {if (x <800/2 & Amp;; & Amp; y> 480/2) {// here ?? For left movement} if (x> 800/2 & Y> 480/2) {// here ?? True movement) true return; }   

Generally, I think I have a position and speed. And I have to update the velocity related situation, but how can I not understand this?

You must update the position of your object in each frame using the DeltaTime and Velocity vector.

Something like this (in render):

  position.set (position.x + velocity.x * delta, position. Y + velocity.y * delta);   

and:

  public boolean touchdown (int x, int y, int pointer, int button) {if (x <800/2 & Amp; Amp; y> 480/2) {// here ?? Velocity.x = -10 for left movement; } If (x> 800/2 & Y> 480/2) {// here ?? Velocity.x = 10 for correct movement; } Back true; } Public Boolean Touchup (int x, int y, int pointer, int button) {velocity.x = 0; }    

No comments:

Post a Comment