Back to project page ssniper-andengine.
The source code is released under:
Apache License
If you think the Android project ssniper-andengine listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.cladophora.ssniper.scene; // w ww . ja va 2s . co m import android.widget.Toast; import com.cladophora.ssniper.BaseActivity; import org.andengine.entity.IEntity; import org.andengine.entity.modifier.DelayModifier; import org.andengine.entity.modifier.IEntityModifier.IEntityModifierListener; import org.andengine.entity.scene.Scene; import org.andengine.entity.scene.background.Background; import org.andengine.entity.sprite.Sprite; import org.andengine.opengl.texture.TextureOptions; import org.andengine.opengl.texture.atlas.ITextureAtlas; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; import org.andengine.opengl.texture.atlas.bitmap.source.IBitmapTextureAtlasSource; import org.andengine.opengl.texture.region.ITextureRegion; import org.andengine.util.color.Color; import org.andengine.util.modifier.IModifier; public class SplashScene extends Scene { BaseActivity activity; public Sprite logo; public ITextureRegion mCladophoraTR; public BitmapTextureAtlas mBitmapTextureAtlas; final private int SPLASH_DURATION = 3; public SplashScene() { setBackground(new Background(Color.WHITE)); activity = BaseActivity.getSharedInstance(); loadResources(); loadGraphics(); } void loadResources() { DelayModifier delayModifier = new DelayModifier(SPLASH_DURATION, new IEntityModifierListener() { @Override public void onModifierStarted(IModifier<IEntity> arg0, IEntity arg1) { } @Override public void onModifierFinished(IModifier<IEntity> arg0, IEntity arg1) { // unload logo logo.dispose(); mBitmapTextureAtlas.unload(); logo.detachSelf(); setChildScene(new InstructionScene()); } } ); registerEntityModifier(delayModifier); } private void loadGraphics() { BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); final ITextureAtlas.ITextureAtlasStateListener.TextureAtlasStateAdapter<IBitmapTextureAtlasSource> textureAtlasStateListener = new ITextureAtlas.ITextureAtlasStateListener.TextureAtlasStateAdapter<IBitmapTextureAtlasSource>() { @Override public void onTextureAtlasSourceLoadExeption(final ITextureAtlas<IBitmapTextureAtlasSource> pTextureAtlas, final IBitmapTextureAtlasSource pBitmapTextureAtlasSource, final Throwable pThrowable) { activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity, "Failed loading TextureSource: " + pBitmapTextureAtlasSource.toString(), Toast.LENGTH_LONG).show(); } }); } }; mBitmapTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 920, 360, TextureOptions.BILINEAR, textureAtlasStateListener); mCladophoraTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, activity, "cladophora.png", 0, 0); mBitmapTextureAtlas.load(); logo = new Sprite((BaseActivity.CAMERA_HEIGHT / 2) - (360 / 2), (BaseActivity.CAMERA_WIDTH / 2) - (920 / 2), mCladophoraTR, activity.getVertexBufferObjectManager()); logo.detachSelf(); attachChild(logo); } }