简体   繁体   English

如何在AndEngine中更改场景

[英]How to Change Scene in AndEngine

I am Developing a game in AndEngine Gles2. 我正在用AndEngine Gles2开发游戏。 I have splash scene, loading scene, menu scene and Level1 scene. 我有启动场景,加载场景,菜单场景和Level1场景。 I am using a Screen Manager to manage all scenes through which i can easily switch between splash, loading and menu scene, the level1 scene is also loaded from menu perfectly but problem occur when i go back to menu scene on the completion of level, screen turned to black and nothing shown after that. 我正在使用屏幕管理器来管理所有可以轻松在启动,加载和菜单场景之间切换的场景,level1场景也可以完美地从菜单加载,但是当我在完成关卡,屏幕时返回菜单场景时会出现问题变成黑色,之后什么也没显示。 I think the problem is with unloading the resources of Level1 because the switching between other scene is perfect. 我认为问题在于卸载Level1的资源,因为其他场景之间的切换是完美的。 I can't give complete code, as it is to much lengthy. 我不能给出完整的代码,因为它很长。

I am using bitmapTexture region, Sprites, bodies, physics Word, hud and fixtures etc. here is my unload method.. 1 more thing when i loaded the menu scene at the end of level 1 screen turn to black, but the music played and all logs are showed in logcat which i set in menu scene. 我正在使用bitmapTexture区域,子画面,实体,物理Word,hud和固定装置等。这是我的卸载方法。当我在1级屏幕末尾加载菜单场景时,还有1件事变成黑色,但是播放的音乐和所有日志都显示在我在菜单场景中设置的logcat中。

unload(){
setChildrenIgnorUpdate();
clearChildScene();
clearEntityModifier();
clearTouchAreas();
clearUpdateHandler();
BitmapTextureManager.getInstance().destroyInstance();
destroyPhysics();
}  

Please Any help... 请任何帮助...

I think your problem is here 我想你的问题在这里

BitmapTextureManager.getInstance().destroyInstance();

are you re-initializing the texture resources when your go back to the menu scene? 返回菜单场景时是否要重新初始化纹理资源? Because it sounds as if everything is working but your textures are destroyed. 因为听起来好像一切正​​常,但是纹理被破坏了。

I think unloading of texture creates problem for you. 我认为卸载纹理会给您带来麻烦。

As per my opinion load all graphics of the game at the time of loading scene. 根据我的观点,在加载场景时加载游戏的所有图形。 Then don't unload the graphics. 然后,不要卸载图形。 I want to say that only game scene graphics which is changing per level that only need to unload and load it again. 我想说的是,仅在每个级别上变化的游戏场景图形只需要卸载并再次加载即可。

Don't unload all graphics and load it again. 不要卸载所有图形并再次加载。 Only load once which are fix for the game and keep in graphics memory of the device. 仅加载一次游戏修复程序,并将其保留在设备的图形内存中。

Overflowing of graphic memory creates this type of abnormal behaviour. 图形内存溢出会导致这种异常行为。

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

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