Java tutorial
/* * Copyright 2012 Aurelien Ribon * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package dorkbox.tweenengine.demo; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import dorkbox.accessors.SpriteAccessor; import dorkbox.tweenengine.Timeline; import dorkbox.tweenengine.Tween; import dorkbox.tweenengine.UpdateAction; import dorkbox.tweenengine.demo.tests.Functions; import dorkbox.tweenengine.demo.tests.Info; import dorkbox.tweenengine.demo.tests.Intro; import dorkbox.tweenengine.demo.tests.Repetitions; import dorkbox.tweenengine.demo.tests.SimpleTimeline; import dorkbox.tweenengine.demo.tests.SimpleTween; import dorkbox.tweenengine.demo.tests.TimeManipulation; import dorkbox.tweenengine.demo.tests.Types; import dorkbox.tweenengine.demo.tests.Waypoints; /** * @author Aurelien Ribon | http://www.aurelienribon.com/ */ public class App implements ApplicationListener { private SplashScreen splashScreen; private Launcher launcherScreen; private boolean isLoaded = false; @Override public void create() { Tween.setWaypointsLimit(10); Tween.setCombinedAttributesLimit(3); Tween.registerAccessor(Sprite.class, new SpriteAccessor()); Tween.setPoolSize(1000); Timeline.setPoolSize(1000); Assets inst = Assets.inst(); inst.load(Test.location + "splash/pack", TextureAtlas.class); inst.load(Test.location + "launcher/pack", TextureAtlas.class); inst.load(Test.location + "test/pack", TextureAtlas.class); inst.load(Test.location + "arial-16.fnt", BitmapFont.class); inst.load(Test.location + "arial-18.fnt", BitmapFont.class); inst.load(Test.location + "arial-20.fnt", BitmapFont.class); inst.load(Test.location + "arial-24.fnt", BitmapFont.class); } @Override public void dispose() { Assets.inst().dispose(); if (splashScreen != null) splashScreen.dispose(); if (launcherScreen != null) launcherScreen.dispose(); } @Override public void render() { if (isLoaded) { if (splashScreen != null) splashScreen.render(); if (launcherScreen != null) launcherScreen.render(); } else { if (Assets.inst().getProgress() < 1) { Assets.inst().update(); } else { launch(); isLoaded = true; } } } @Override public void resize(int width, int height) { } @Override public void pause() { } @Override public void resume() { } private void launch() { // will be called once render is done, and timeline is complete splashScreen = new SplashScreen(new UpdateAction<Void>() { @Override public void onEvent(final Void updatedObject) { Test[] tests = new Test[] { new Intro(), new Info(), new SimpleTween(), new SimpleTimeline(), new Repetitions(), new TimeManipulation(), new Waypoints(), new Functions(), new Types() }; splashScreen.dispose(); splashScreen = null; launcherScreen = new Launcher(tests); } }); } }