简体   繁体   English

我在没有Rokon的情况下创建了一个UI,但是我想稍后再启动Rokon来运行我的游戏,可以这样做吗?

[英]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.

相关问题 我可以在没有任何 UI 的情况下运行我的 flutter 代码吗.. 就像 api 调用一样 - Can I run my flutter code without any UI.. like an api call 适用于教育iPad或Android应用程序的高级2D图形开发? (正在处理?rokon?) - high-level 2D graphics development for an education iPad or Android app? (Processing? rokon?) 如何在不干扰程序UI的情况下播放声音? - How do I play a sound without any interference with the UI of my program? 如何在启动时启动应用程序并允许像 whatsapp 一样运行 - How do I start app on boot and allow run like whatsapp 如何在项目中添加类似UI的“解锁环”? - How do I add a “unlock ring” like UI to my project? 如何分析我使用 Game Guardian 创建的 memory 转储? - How do I analyze the memory dump I created with Game Guardian? 如何在不覆盖以前版本的情况下将新版本的android游戏安装到android设备? - how do i install a new version of my android game to my android device without overwriting the previous version? 如果我这样做的话,在android中创建的文件将在哪里 - Where will be a file created in android if I do it like this 我如何学习设计这样的UI? - How do I learn to design a UI like this? 我的游戏需要多线程吗? - Do I need multithreading for my game?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM