If you think the Android project DolphinOES listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*******************************************************************************
* Copyright 2014 See AUTHORS file.//www.java2s.com
*
* 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 com.sidereal.dolphinoes.architecture.core.assetload;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.sidereal.dolphinoes.architecture.DolphinOES;
import com.sidereal.dolphinoes.architecture.GameScene;
import com.sidereal.dolphinoes.ui.TextBuilder;
/** Default {@link AssetLoadHandler} passed to the
* {@link LoadingScreenConfiguration#assetLoadingHandler} in the
* {@link LoadingScreenConfiguration} default constructor. Shows the progress in
* loading assets by displaying a percentage.
* <p>
* As soon as the game is done with loading assets, new scene will be loaded.
*
* @author Claudiu Bele */publicclass LoadingPercentage extends AssetLoadHandler
{
// region fields
TextBuilder text;
// endregion fields
// region constructors
public LoadingPercentage(GameScene scene, Object... params)
{
super(scene);
}
@Override
publicvoid createObject(Object... params)
{
if (text != null)
return;
if (!DolphinOES.assets.contains(DolphinOES.assets.frameworkAssetsFolder
+ "Blocks4.fnt")
|| !DolphinOES.assets
.contains(DolphinOES.assets.frameworkAssetsFolder
+ "Blocks4_0.png"))
return;
text = new TextBuilder(scene, true);
text.setScale(Gdx.graphics.getWidth() / 600f);
text.setColor(Color.WHITE);
text.setAlpha(1);
text.pos.set(gameBatch.camera.position.x,gameBatch.camera.viewportHeight / 10 * 1.6f);
}
// endregion constructors
// region methods
@Override
publicvoid updateProgress(float progress)
{
if (text == null)
createObject();
else
{
text.setText("Loading \r\n" + ((int) (progress * 1000) / 10f)
+ " %", Color.WHITE);
}
}
@Override
publicvoid onResize(float x, float y, float oldX, float oldY)
{
if (text != null)
{
text.pos.setX(Gdx.graphics.getWidth() / 2f);
text.pos.setY(Gdx.graphics.getHeight() / 10 * 1.6f);
}
}
@Override
publicboolean canGoToNextScene()
{
return true;
}
// endregion methods
}