Libgdx吐温不工作在Android [英] Libgdx tween not working on Android

查看:195
本文介绍了Libgdx吐温不工作在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展我的libgdx第一款Android游戏,采用的魅力这个惊人的教程(的http://www.kilobolt.com/day-11-supporting-iosandroid--splashscreen-menus-and-tweening.html).一切工作正常,除了我使用的闪屏,显示我的公司标志的补间。怪异的是,标志工作在桌面版本就好了,但在Android版本没有被显示

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();
    }
}

非常感谢你的帮助。我很抱歉,如果在任何时刻,我无法解释自己,但英语不是我的主要语言。如果您需要任何额外的一块code,我可以添加它。

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.

推荐答案

您需要确保您导出构建路径补间jar文件。对于Eclipse,您可以在项目上单击右键,选择构建路径>配置构建路径,转到排序和导出选项卡上的右侧,并确保补间jar文件的检查列出那里。

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.

这篇关于Libgdx吐温不工作在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆