开发者

Stackoverflow when trying to run the Text example in the AndEngineExampleLauncher

开发者 https://www.devze.com 2023-04-09 19:45 出处:网络
Hey Game Engine Folks, This is a question for those who worked with AndEngine for Android. I\'ve a problem getting the Text example of the AndEngineExampleLauncher working!

Hey Game Engine Folks,

This is a question for those who worked with AndEngine for Android.

I've a problem getting the Text example of the AndEngineExampleLauncher working!

It throws the following exception:

09-30 10:11:19.940: ERROR/AndroidRuntime(466): FATAL EXCEPTION: main
09-30 10:11:19.940: ERROR/AndroidRuntime(466): java.lang.StackOverflowError
09-30 10:11:19.940: ERROR/AndroidRuntime(466):     at org.anddev.andengine.ui.activity.BaseGameActivity.getFontManager(BaseGameActivity.java:137)
09-30 10:11:19.940: ERROR/AndroidRuntime(466):     at org.anddev.andengine.ui.activity.BaseGameActivity.getFontManager(BaseGameActivity.java:137)
09-30 10:11:19.940: ERROR/AndroidRuntime(466):     at org.anddev.andengine.ui.activity.Base开发者_如何学编程GameActivity.getFontManager(BaseGameActivity.java:137)

I've googled that error and it seems that some other guys having the same problem, but I couldn't find a solution posted anywhere!

Have anybody been able to get this example working without getting this 80's & 90's StackOverflowError!.

Really appreciate your help.

Thanks, Mohamed A.Karim


This is very odd, but I took the time to debug the AndEngine BaseGameActivity.java class from the AndEngine src and I've found the cause of the problem:

Here is the shipped with getFontManger() method:

    public FontManager getFontManager() {
    return this.getFontManager();
}

This is the typical StackOverFlow cause... The very classic one.

I've changed that method to be:

    public FontManager getFontManager() {
    return this.mEngine.getFontManager();
}

And the AndEngine Text example is working like charm now.

So, here are the steps I've done to get the AndEngine Text example working: 1- Go to the AndEngine Project (Source code you import to your game) 2- Go to class org.anddev.andengine.ui.activity.BaseGameActivity.java 3- Go to method: getFontManager() 4- Change the return value From: return this.getFontManager(); To: return this.mEngine.getFontManager();

I hope this can be a help for anybody who has the same problem

Really appreciate the great effort from @Nicolas Gramlich for creating such an incredible game engine.

Thanks, Mohamed.

0

精彩评论

暂无评论...
验证码 换一张
取 消