Skip to content

Commit

Permalink
fixed problem with splash atlas was too small, started menu buttons a…
Browse files Browse the repository at this point in the history
…dded
  • Loading branch information
john kavanagh committed Aug 30, 2015
1 parent 501acbd commit 7c30a6b
Show file tree
Hide file tree
Showing 19 changed files with 109 additions and 53 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:name="GameActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|mcc|mnc">
<intent-filter>
Expand Down
2 changes: 1 addition & 1 deletion bin/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:name="GameActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|mcc|mnc">
<intent-filter>
Expand Down
Binary file modified bin/BawsePhighter.apk
Binary file not shown.
Binary file modified bin/classes.dex
Binary file not shown.
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/GameActivity.class
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/ResourcesManager.class
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/SceneManager$SceneType.class
Binary file not shown.
Binary file modified bin/classes/com/bawsephighter/SceneManager.class
Binary file not shown.
Binary file not shown.
Binary file added bin/classes/com/bawsephighter/SplashScene.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified bin/dexedLibs/appcompat_v7-e1ceeea49e4ff6e6ca6882136ade5f89.jar
Binary file not shown.
Binary file modified bin/resources.ap_
Binary file not shown.
40 changes: 27 additions & 13 deletions src/com/bawsephighter/GameActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
import org.andengine.engine.Engine;
import org.andengine.engine.LimitedFPSEngine;
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.WakeLockOptions;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.ui.activity.BaseGameActivity;




public class GameActivity extends BaseGameActivity{
private Camera camera;
private ResourcesManager resourcesManager;
Expand All @@ -28,24 +27,39 @@ public EngineOptions onCreateEngineOptions(){
@Override
public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception {
ResourcesManager.prepareManager(mEngine, this, camera, getVertexBufferObjectManager());
resourcesManager = ResourcesManager.getInstance();
setResourcesManager(ResourcesManager.getInstance());
pOnCreateResourcesCallback.onCreateResourcesFinished();
}

@Override
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {

public Engine onCreateEngine(EngineOptions pEngineOptions) {
return new LimitedFPSEngine(pEngineOptions, 60);
}

public ResourcesManager getResourcesManager() {
return resourcesManager;
}

public void setResourcesManager(ResourcesManager resourcesManager) {
this.resourcesManager = resourcesManager;
}

@Override
public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {

public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {
SceneManager.getInstance().createSplashScene(pOnCreateSceneCallback);
}

@Override
public Engine onCreateEngine(EngineOptions pEngineOptions)
{
return new LimitedFPSEngine(pEngineOptions, 60);
public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
mEngine.registerUpdateHandler(new TimerHandler(2f, new ITimerCallback() {
public void onTimePassed(final TimerHandler pTimerHandler) {
mEngine.unregisterUpdateHandler(pTimerHandler);
// load menu resources, create menu scene
// set menu scene using scene manager
// disposeSplashScene();
// READ NEXT ARTICLE FOR THIS PART.
}
}));
pOnPopulateSceneCallback.onPopulateSceneFinished();
}

}
}
52 changes: 14 additions & 38 deletions src/com/bawsephighter/ResourcesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,29 @@

import com.bawsephighter.GameActivity;

public class ResourcesManager
{
//---------------------------------------------
// VARIABLES
//---------------------------------------------

public class ResourcesManager{
private static final ResourcesManager INSTANCE = new ResourcesManager();

public Engine engine;
public GameActivity activity;
public Camera camera;
public VertexBufferObjectManager vbom;

//---------------------------------------------
// TEXTURES & TEXTURE REGIONS
//---------------------------------------------

//---------------------------------------------
// CLASS LOGIC
//---------------------------------------------
public ITextureRegion splash_region;
private BitmapTextureAtlas splashTextureAtlas;

public void loadMenuResources()
{
public void loadMenuResources(){
loadMenuGraphics();
loadMenuAudio();
}

public void loadGameResources()
{
public void loadGameResources(){
loadGameGraphics();
loadGameFonts();
loadGameAudio();
}

private void loadMenuGraphics()
{
private void loadMenuGraphics(){

}

Expand All @@ -74,25 +61,18 @@ private void loadGameAudio()

}

public void loadSplashScreen()
{

public void loadSplashScreen(){
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("");
splashTextureAtlas = new BitmapTextureAtlas(activity.getTextureManager(), 400, 400, TextureOptions.BILINEAR);
splash_region = BitmapTextureAtlasTextureRegionFactory.createFromAsset(splashTextureAtlas, activity, "splash.png", 0, 0);
splashTextureAtlas.load();
}

public void unloadSplashScreen()
{

public void unloadSplashScreen(){
splashTextureAtlas.unload();
splash_region = null;
}

/**
* @param engine
* @param activity
* @param camera
* @param vbom
* <br><br>
* We use this method at beginning of game loading, to prepare Resources Manager properly,
* setting all needed parameters, so we can latter access them from different classes (eg. scenes)
*/
public static void prepareManager(Engine engine, GameActivity activity, Camera camera, VertexBufferObjectManager vbom)
{
getInstance().engine = engine;
Expand All @@ -101,10 +81,6 @@ public static void prepareManager(Engine engine, GameActivity activity, Camera c
getInstance().vbom = vbom;
}

//---------------------------------------------
// GETTERS AND SETTERS
//---------------------------------------------

public static ResourcesManager getInstance()
{
return INSTANCE;
Expand Down
19 changes: 19 additions & 0 deletions src/com/bawsephighter/SceneManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.bawsephighter;

import java.io.IOException;

import org.andengine.engine.Engine;
import org.andengine.ui.IGameInterface.OnCreateSceneCallback;

import com.bawsephighter.base.BaseScene;

Expand Down Expand Up @@ -35,6 +38,8 @@ public enum SceneType
SCENE_LOADING,
}



//---------------------------------------------
// CLASS LOGIC
//---------------------------------------------
Expand Down Expand Up @@ -85,4 +90,18 @@ public BaseScene getCurrentScene()
{
return currentScene;
}

public void createSplashScene(OnCreateSceneCallback pOnCreateSceneCallback){
ResourcesManager.getInstance().loadSplashScreen();
splashScene = new SplashScene();
currentScene = splashScene;
pOnCreateSceneCallback.onCreateSceneFinished(splashScene);
}

private void disposeSplashScene(){
ResourcesManager.getInstance().unloadSplashScreen();
splashScene.disposeScene();
splashScene = null;
}

}
47 changes: 47 additions & 0 deletions src/com/bawsephighter/SplashScene.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.bawsephighter;

import org.andengine.engine.camera.Camera;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.util.GLState;

import com.bawsephighter.base.BaseScene;
import com.bawsephighter.SceneManager.SceneType;

public class SplashScene extends BaseScene
{
private Sprite splash;

@Override
public void createScene(){
splash = new Sprite(0, 0, resourcesManager.splash_region, vbom){
@Override
protected void preDraw(GLState pGLState, Camera pCamera)
{
super.preDraw(pGLState, pCamera);
pGLState.enableDither();
}
};

splash.setScale(1.5f);
splash.setPosition(200, 100);
attachChild(splash);
}

@Override
public void onBackKeyPressed(){

}

@Override
public SceneType getSceneType(){
return SceneType.SCENE_SPLASH;
}

@Override
public void disposeScene(){
splash.detachSelf();
splash.dispose();
this.detachSelf();
this.dispose();
}
}

0 comments on commit 7c30a6b

Please sign in to comment.