java - How to make sprites move from one place to another place -


i'm using libgdx create game got problem: how make sprite move 1 location marked click location marked click? need smooth animation.

here's code have done: main application implements applistener , inputlistener.

public class lgame implements applicationlistener {  public static field field; private spritebatch bat; private listener listener;  @override public void create() {     field = new field();     bat = new spritebatch();     listener = new listener();     gdx.input.setinputprocessor(listener); }  @override public void render() {     bat.begin();     bat.draw(field.gettexture(), 0, 0);     for(int = 0; <= 31; i++)         if(!field.getfigure(i).iseaten())             bat.draw(field.getfigure(i).gettexture(), field.getfigure(i).getposx()*64, field.getfigure(i).getposy()*64);     bat.end(); } 

"render" method iterate collection "field" contained objects on scene.

public class listener implements inputprocessor {  private int inx; private int iny; private int tomove = 32; private boolean iswhiteturn = true;  @override public boolean touchdown(int arg0, int arg1, int arg2, int arg3) {     inx = arg0 / 64;     iny = (512 - arg1) / 64;     if(tomove == 32){         if(lgame.field.poll(inx, iny) != 32 && lgame.field.getfigure(lgame.field.poll(inx, iny)).iswhite == iswhiteturn ){             tomove = lgame.field.poll(inx, iny);         }     }else{         if(lgame.field.poll(inx, iny) != 32){             if(lgame.field.getfigure(tomove).ismoveright(inx, iny)){                 lgame.field.eatfigure(lgame.field.poll(inx, iny));                 lgame.field.setfigurepos(inx, iny, tomove);                 iswhiteturn = !iswhiteturn;                 tomove = 32;             }else{                 tomove = 32;             }         }else{             if(lgame.field.getfigure(tomove).ismoveright(inx, iny)){                 lgame.field.setfigurepos(inx, iny, tomove);                 iswhiteturn = !iswhiteturn;                 tomove = 32;             }else{                 tomove = 32;             }         }     }     return false; } 

"touchdown" method called when mouse clicked; have done changing position of object, need animate changing.

look universal tween engine

it can used create smooth easing between variable(s). movement animation, fading, scaling or can think of.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -