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 s开发者_如何学Ctart 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.
I've 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.
You are using forcePortrait(). Did you set orientation to portrait for this activity in the manifest?
精彩评论