Libgdx tween not working on Android

梦想的初衷 提交于 2019-12-22 18:30:04

问题


I'm developing my first android game with libgdx, using as a base this amazing tutorial (http://www.kilobolt.com/day-11-supporting-iosandroid--splashscreen-menus-and-tweening.html). Everything works properly except for the tweening that I’m using in the splash screen to show the logo of my “company”. The weird part is that the logo works just fine in the desktop version, but in the android version is not being showed.

I’m using the same class that they used in the app developed in the tutorial. By the way, this app’s splash screen works fine in both versions.

I have compared my app and the tutorial’s app, but I found no differences except for this on the package explorer. I don't know if it means something:

http://i1223.photobucket.com/albums/dd507/victormmenendez/tut.jpg

package com.victor.Screens;

import aurelienribon.tweenengine.BaseTween;
import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenCallback;
import aurelienribon.tweenengine.TweenEquations;
import aurelienribon.tweenengine.TweenManager;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.victor.TweenAccessors.SpriteAccessor;
import com.victor.FZHelpers.AssetLoader;
import com.victor.FZombies.FZGame;

public class SplashScreen implements Screen
{

    private TweenManager manager;
    private SpriteBatch batcher;
    private Sprite sprite;
    private FZGame game;

    public SplashScreen(FZGame game)
    {
        this.game = game;
    }

    @Override
    public void show()
    {
        sprite = new Sprite(AssetLoader.logo);
        sprite.setColor(1, 1, 1, 0);

        float width = Gdx.graphics.getWidth();
        float height = Gdx.graphics.getHeight();
        float desiredWidth = width * .4f;
        float scale = desiredWidth / sprite.getWidth();

        sprite.setSize(sprite.getWidth() * scale, sprite.getHeight() * scale);
        sprite.setPosition((width / 2) - (sprite.getWidth() / 2), (height / 2) - (sprite.getHeight() / 2));
        setupTween();
        batcher = new SpriteBatch();

    }

    private void setupTween()
    {
        Tween.registerAccessor(Sprite.class, new SpriteAccessor());
        manager = new TweenManager();

        TweenCallback cb = new TweenCallback()
        {
            @Override
            public void onEvent(int type, BaseTween<?> source)
            {
                game.setScreen(new GameScreen());
            }
        };

        Tween.to(sprite, SpriteAccessor.ALPHA, .8f).target(1).ease(TweenEquations.easeInOutQuad).repeatYoyo(1, .4f).setCallback(cb).setCallbackTriggers(TweenCallback.COMPLETE).start(manager);
    }

    @Override
    public void render(float delta)
    {
        manager.update(delta);
        Gdx.gl.glClearColor(1, 0, 0, 1);
        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
        batcher.begin();
        sprite.draw(batcher);
        batcher.end();
    }
}

Thank you very much for your help. I'm sorry if in any moment I couldn’t explain myself, but English is not my primary language. If you need any extra piece of code, I can add it.


回答1:


You need to make sure you export the tween jar files in your Build Path. For Eclipse, you can Right-click on the project, choose "Build Path" > "Configure Build Path", go to the "Order and Export" tab on the right side, and make sure that the tween jar files are checked in the list there.



来源:https://stackoverflow.com/questions/22080642/libgdx-tween-not-working-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!