views:

80

answers:

1

I started using Rokon to create the graphical portion of my game but when it was finished I had a lot of trouble creating a menu system and doing alerts with it. Discouraged, I started over without the game engine and made a nice looking UI. When the user clicks start game I want to run Rokon to load the graphics I made, but Ive tried everything I can think of and can't get it to not force close. I just did a basic call to make a new GameEngine since the GameEngine does everything else with the new view and the rest. Heres the code in my MainActivity(ignore the difficulty stuff, I just want to load the one difficulty for now):

protected void startGame(int difficulty) { // TODO Auto-generated method stub Context context = getApplicationContext(); int duration = Toast.LENGTH_SHORT;

Toast toast = Toast.makeText(context, "Game Started!" + "\n" + "Difficulty set to: " + difficulty, duration); toast.show();

switch(difficulty){ case 1: { //Code to start Game on Easy GameEngine easyGame = new GameEngine(); easyGame.onCreate();

Here is the Rokon GameEngine code I am trying to use, I made sure to add the library and other directories it was previously using...

import com.stickycoding.rokon.DrawPriority; import com.stickycoding.rokon.RokonActivity;

public class GameEngine extends RokonActivity {

public static final float GAME_WIDTH = 320f;
public static final float GAME_HEIGHT = 480f;

private GameScene scene;

public void onCreate() {
    debugMode();
    forceFullscreen();
    forcePortrait();
    setGameSize(GAME_WIDTH, GAME_HEIGHT);
    setDrawPriority(DrawPriority.PRIORITY_VBO);
    setGraphicsPath("textures/");
    createEngine();

}

public void onLoadComplete() {
    Textures.load();
    setScene(scene = new GameScene());
}

}

Maybe they just aren't compatible with each other and I have to stick with using Rokon from the start, but there's gotta be a way to make this work... Thanks guys

Ive been playing around with the code and the debugger alot trying to figure out which part of the code wont work, and the error lies when I call createEngine(); if that helps at all... Some of the other code could be commented out to make it work, so Ive narrowed it down to that line.

A: 

You are using forcePortrait(). Did you set orientation to portrait for this activity in the manifest?

Yoni S.
I did set the orientation in the manifest. I threw the idea out and worked with a different concept, but I believe the error was my layout. I learned later on how to put a SurfaceView into a layout and I think that was the main problem. I didn't go back and try it out, but I think the fact that I wasn't using a FrameLayout with the View in it was the issue...
Aaron
I guess I could have answered my question but I forgot about it haha
Aaron