Download: http://www.mediafire.com/?ar2w8zg4giigpxo
package matim.development;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.handler.timer.ITimerCallback;
import org.andengine.engine.handler.timer.TimerHandler;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
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.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.util.GLState;
import org.andengine.ui.activity.BaseGameActivity;
import android.util.Log;
import android.view.Display;
/**
* @author Matim Development
* @version 1.0.0
* <br><br>
* https://sites.google.com/site/matimdevelopment/
*/
public class SplashTemplate extends BaseGameActivity
{
private int CAMERA_WIDTH ;
private int CAMERA_HEIGHT;
private Camera camera;
private Scene splashScene;
private Scene mainScene;
private BitmapTextureAtlas splashTextureAtlas;
private ITextureRegion splashTextureRegion;
private Sprite splash;
Display mDisplay;
private enum SceneType
{
SPLASH,
MAIN,
OPTIONS,
WORLD_SELECTION,
LEVEL_SELECTION,
CONTROLLER
}
private SceneType currentScene = SceneType.SPLASH;
@Override
public EngineOptions onCreateEngineOptions()
{
Log.d("-------onCreateEngineOptions()---------", " ");
mDisplay = getWindowManager().getDefaultDisplay();
CAMERA_HEIGHT = mDisplay.getHeight();
CAMERA_WIDTH = mDisplay.getWidth();
camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new FillResolutionPolicy(), camera);
return engineOptions;
}
@Override
public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception
{
Log.d("-------onCreateResources()---------", " ");
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
splashTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 256, 256, TextureOptions.DEFAULT);
splashTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(splashTextureAtlas, this, "splash.png", 0, 0);
splashTextureAtlas.load();
pOnCreateResourcesCallback.onCreateResourcesFinished();
}
@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception
{
Log.d("-------onCreateScene()---------", " ");
initSplashScene();
pOnCreateSceneCallback.onCreateSceneFinished(this.splashScene);
}
@Override
public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception
{
Log.d("-------onPopulateScene()---------", " ");
mEngine.registerUpdateHandler(new TimerHandler(5f, new ITimerCallback()
{
public void onTimePassed(final TimerHandler pTimerHandler)
{
mEngine.unregisterUpdateHandler(pTimerHandler);
loadResources();
loadScenes();
splash.detachSelf();
mEngine.setScene(mainScene);
currentScene = SceneType.MAIN;
}
}));
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
public void loadResources()
{
Log.d("-------loadResources()()---------", " ");
// Load your game resources here!
}
private void loadScenes()
{
Log.d("-------loadScenes()---------", " ");
// load your game here, you scenes
mainScene = new Scene();
mainScene.setBackground(new Background(50, 50, 50));
}
// ===========================================================
// INITIALIZIE
// ===========================================================
private void initSplashScene()
{
Log.d("-------initSplashScene()---------", " ");
splashScene = new Scene();
splash = new Sprite(0, 0, splashTextureRegion, mEngine.getVertexBufferObjectManager())
{
@Override
protected void preDraw(GLState pGLState, Camera pCamera)
{
super.preDraw(pGLState, pCamera);
pGLState.enableDither();
}
};
splash.setScale(1.5f);
splash.setPosition((CAMERA_WIDTH - splash.getWidth()) * 0.5f, (CAMERA_HEIGHT - splash.getHeight()) * 0.5f);
splashScene.attachChild(splash);
}
}
package matim.development;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.handler.timer.ITimerCallback;
import org.andengine.engine.handler.timer.TimerHandler;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.FillResolutionPolicy;
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.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.util.GLState;
import org.andengine.ui.activity.BaseGameActivity;
import android.util.Log;
import android.view.Display;
/**
* @author Matim Development
* @version 1.0.0
* <br><br>
* https://sites.google.com/site/matimdevelopment/
*/
public class SplashTemplate extends BaseGameActivity
{
private int CAMERA_WIDTH ;
private int CAMERA_HEIGHT;
private Camera camera;
private Scene splashScene;
private Scene mainScene;
private BitmapTextureAtlas splashTextureAtlas;
private ITextureRegion splashTextureRegion;
private Sprite splash;
Display mDisplay;
private enum SceneType
{
SPLASH,
MAIN,
OPTIONS,
WORLD_SELECTION,
LEVEL_SELECTION,
CONTROLLER
}
private SceneType currentScene = SceneType.SPLASH;
@Override
public EngineOptions onCreateEngineOptions()
{
Log.d("-------onCreateEngineOptions()---------", " ");
mDisplay = getWindowManager().getDefaultDisplay();
CAMERA_HEIGHT = mDisplay.getHeight();
CAMERA_WIDTH = mDisplay.getWidth();
camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new FillResolutionPolicy(), camera);
return engineOptions;
}
@Override
public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception
{
Log.d("-------onCreateResources()---------", " ");
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
splashTextureAtlas = new BitmapTextureAtlas(this.getTextureManager(), 256, 256, TextureOptions.DEFAULT);
splashTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(splashTextureAtlas, this, "splash.png", 0, 0);
splashTextureAtlas.load();
pOnCreateResourcesCallback.onCreateResourcesFinished();
}
@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception
{
Log.d("-------onCreateScene()---------", " ");
initSplashScene();
pOnCreateSceneCallback.onCreateSceneFinished(this.splashScene);
}
@Override
public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception
{
Log.d("-------onPopulateScene()---------", " ");
mEngine.registerUpdateHandler(new TimerHandler(5f, new ITimerCallback()
{
public void onTimePassed(final TimerHandler pTimerHandler)
{
mEngine.unregisterUpdateHandler(pTimerHandler);
loadResources();
loadScenes();
splash.detachSelf();
mEngine.setScene(mainScene);
currentScene = SceneType.MAIN;
}
}));
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
public void loadResources()
{
Log.d("-------loadResources()()---------", " ");
// Load your game resources here!
}
private void loadScenes()
{
Log.d("-------loadScenes()---------", " ");
// load your game here, you scenes
mainScene = new Scene();
mainScene.setBackground(new Background(50, 50, 50));
}
// ===========================================================
// INITIALIZIE
// ===========================================================
private void initSplashScene()
{
Log.d("-------initSplashScene()---------", " ");
splashScene = new Scene();
splash = new Sprite(0, 0, splashTextureRegion, mEngine.getVertexBufferObjectManager())
{
@Override
protected void preDraw(GLState pGLState, Camera pCamera)
{
super.preDraw(pGLState, pCamera);
pGLState.enableDither();
}
};
splash.setScale(1.5f);
splash.setPosition((CAMERA_WIDTH - splash.getWidth()) * 0.5f, (CAMERA_HEIGHT - splash.getHeight()) * 0.5f);
splashScene.attachChild(splash);
}
}
No comments:
Post a Comment