Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:18:24+00:00 2026-06-08T04:18:24+00:00

I’m learning to use libgdx with universal-tween-engine and haven’t been able to figure out

  • 0

I’m learning to use libgdx with universal-tween-engine and haven’t been able to figure out how to touch (or click on the desktop app) a point on the screen and have a texture move all the way to the touched location without keeping the touch or click active until the end-point is reached.

When the touch event is initiated, the animation begins and the graphic moves towards the location. The graphic will follow the finger/mouse-pointer if a touch and drag is initiated. If I touch a point, the graphic will move towards the point until the touch is released. Then it stops where it was when touch is released.

I’m looking to touch-and-release and have that graphic move to the touched point, and am probably not understanding something about the tween engine implementation. I’ve pasted the tweening code below.

    public void render() {

            camera.update();

            batch.setProjectionMatrix(camera.combined);
            batch.begin();
            batch.draw(texture.getTexture(), texture.getBoundingBox().x, texture.getBoundingBox().y);
            batch.end();

            Tween.registerAccessor(Plane.class, new TextureAccessor());
            TweenManager planeManager = new TweenManager();

            float newX = 0;
            float newY = 0;
            boolean animateOn = false;

            if(Gdx.input.isTouched()) {
                    newX = Gdx.input.getX();

                    newY = Gdx.input.getY();

                    animateOn = true;
            }

            if (animateOn == true && (texture.getX() != newX || texture.getY() != newY)) {
                Tween.to(texture, TextureAccessor.POSITION_XY, 10)
                    .target(newX, newY)
                    .ease(TweenEquations.easeNone)
                    .start(planeManager);

                    planeManager.update(1);

                    if (texture.getX() == newX && texture.getY() == newY) {
                        animateOn = false;
                    }
            }

    }

Originally, I had the tweening code inside the conditional for isTouched() and didn’t use the newX, newY or animateOn variables. I thought using isTouched() to only set the new coordinates and animation state would then make the loop trigger the tween. The older code looked like this:

    if(Gdx.input.isTouched()) {
            newX = Gdx.input.getX();

            newY = Gdx.input.getY();

            Tween.to(texture, TextureAccessor.POSITION_XY, 10)
                .target(newX, newY)
                .ease(TweenEquations.easeNone)
                .start(planeManager);

            planeManager.update(1);
    }

I’ve also tried using justTouched(), but the graphic would only move very slightly toward the touched point.

I’ve been struggling with this for a few hours, I’d really appreciate it if anyone could point me in the right direction.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:18:27+00:00Added an answer on June 8, 2026 at 4:18 am
    Tween.registerAccessor(Plane.class, new TextureAccessor());
    TweenManager planeManager = new TweenManager();
    

    These two lines should go in the create() method, not the render() one! Here, you’re instantiating a new manager on every frame, you only need one manager, that’s all, not an army of them!

    Also, you need to update the manager on every frame, not just when animateOn is true, else you’ll need to keep your finger pressed…

    The correct code is as follows, learn from it, you’ll get a better understanding of how the Tween Engine works 🙂

    // Only one manager is needed, like a Spritebatch
    private TweenManager planeManager;
    
    public void create() {
        Tween.registerAccessor(Plane.class, new TextureAccessor());
        planeManager = new TweenManager();
    }
    
    public void render() {
        // The manager needs to be updated on every frame.
        planeManager.update(Gdx.graphics.getDeltaTime());
    
        camera.update();
    
        batch.setProjectionMatrix(camera.combined);
        batch.begin();
        batch.draw(texture.getTexture(), texture.getBoundingBox().x, texture.getBoundingBox().y);
        batch.end();
    
        // When the user touches the screen, we start an animation.
        // The animation is managed by the TweenManager, so there is
        // no need to use an "animateOn" boolean.
        if (Gdx.input.justTouched()) {
            // Bonus: if there is already an animation running,
            // we kill it to prevent conflicts with the new animation.
            planeManager.killTarget(texture);
    
            // Fire the animation! :D
            Tween.to(texture, TextureAccessor.POSITION_XY, 10)
                .target(Gdx.input.getX(), Gdx.input.getY())
                .ease(TweenEquations.easeNone)
                .start(planeManager);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I know there's a lot of other questions out there that deal with this
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.