[英]I created a UI without Rokon, but I'd like to start Rokon later to run my game, any way to do this?
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. 我开始使用Rokon来创建游戏的图形部分,但是当完成时,创建菜单系统并对其进行提醒时会遇到很多麻烦。 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.
当用户单击开始游戏时,我想运行Rokon来加载我制作的图形,但是我已经尝试了所有我能想到的并且不能使它不强制关闭。 I just did a basic call to make a new GameEngine since the GameEngine does everything else with the new view and the rest.
我只是做了一个基本的电话来制作一个新的GameEngine,因为GameEngine用新的视图和其余的东西来做其他的事情。 Heres the code in my MainActivity(ignore the difficulty stuff, I just want to load the one difficulty for now):
这是我的MainActivity中的代码(忽略难度内容,我现在只想加载一个难度):
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... 这是我要使用的Rokon GameEngine代码,我确保添加了以前使用的库和其他目录...
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. 也许它们只是彼此不兼容,我必须从一开始就坚持使用Rokon,但是必须有一种方法可以使这项工作奏效。
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(); 我一直在研究代码和调试器,试图弄清楚代码的哪一部分不起作用,而当我调用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(). 您正在使用forcePortrait()。 Did you set orientation to portrait for this activity in the manifest?
您是否在清单中为此活动设置了纵向方向?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.