简体   繁体   English

如何正确重置AndEngine GLES-2中的场景?

[英]How to properly reset a scene in AndEngine GLES-2?

I am developing a game in Android using AndEngine GLES-2. 我正在使用AndEngine GLES-2在Android上开发游戏。 I am facing a problem while resetting a scene after player has completed a level. 在玩家完成关卡后重置场景时我遇到了问题。 When I reset the scene, all the sprites lose their positions and tend to appear in each other's positions ie they swap their positions. 当我重置场景时,所有精灵都会失去位置,并且往往会出现在彼此的位置,即他们交换位置。

I have tried all the things like setting all the sprites etc. to null and calling methods like clearUpdateHandlers() and clearEventModifiers() etc. but no success yet. 我已经尝试了所有的事情,比如将所有精灵等设置为null并调用clearUpdateHandlers()和clearEventModifiers()等方法,但还没有成功。

I found out after a lot of googling that engineOptions.getRenderOptions().disableExtensionVertexBufferObjects(); 经过很多googling后我发现了engineOptions.getRenderOptions()。disableExtensionVertexBufferObjects(); method can fix this problem. 方法可以解决这个问题。 So I am trying to invoke it but compiler gives error saying that this method in not defined for RenderOptions class. 所以我试图调用它,但编译器给出了错误,说明这个方法没有为RenderOptions类定义。

I checked the RenderOptions class in org.andengine.engine.options package and the method really does not exist in that class. 我检查了org.andengine.engine.options包中的RenderOptions类,该方法确实不存在。 Am I missing any plug-in or is there any other problem? 我错过了任何插件还是有其他问题? Please help, I am stuck. 请帮忙,我被卡住了。

you need to manually restart the scene, for example: 你需要手动重启场景,例如:

To restart a Scene you can Finish the activity and Start again but different level with SharedPreferences, or Tag's in intents, or you can set position of each Sprite and cler the Scene with: 要重新启动场景,您可以完成活动并重新开始,但是使用SharedPreferences或者意图中的标记不同级别,或者您可以设置每个Sprite的位置并使用以下方式调整场景:

 //detachChild this Sprites that you do not use
 Scene.detachChild(SpriteX);
 //clear the space of memory of each sprite that you do not use
 SpriteX.dispose();
 //unload the bitmaps that you do not use
 BitMapsX.unload();

this method have a seconds to run, but you can use a elegant "hud" in you game, and while charging set in the hud a logo or animation with "loading", best regards 这种方法有一秒钟可以运行,但你可以在你的游戏中使用优雅的“hud”,同时在hud中设置带有“加载”的徽标或动画,最好的问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM