[英]app works on simulator but not on android
I tested my app on android phone and it stopped in the middle of playing, it stops when it is about to change scene.(It works on the simulator.) I debugged it using the instructions by: http://coronalabs.com/blog/2013/07/09/tutorial-basic-debugging/ 我在Android手机上测试了我的应用程序,该应用程序在播放过程中停止运行,在要更改场景时停止运行。(在模拟器上运行。)我使用以下网站上的说明对其进行了调试: http : //coronalabs.com/博客/ 2013/07/09 /教程基本调试/
This is what it gave me in the cmd. 这就是它在cmd中给我的。
beginning of /dev/log/main
.....
I/Corona <24200>:cannonCharge
I/Corona <24200>:shot
I/Corona <24200>:event listener
I/Corona <24200>:Ball is colliding
I/Corona <24200>:Before changing scene
Then it just stops here and then a popout on my phone screen says balloon game has stopped. 然后停在这里,然后手机屏幕上的弹出窗口显示气球游戏已停止。 This part of the code i think went wrong.
我认为这部分代码出错了。
if (event.other == balloons[1]) then
scene.updateScore()
print('Ball is colliding')
balloon1:removeSelf()
balloon1 = nil
balloonText1:removeSelf()
balloonText1 = nil
audio.play(pop)
print('Before changing scene')
storyboard.gotoScene("correct1", "fade", 1000)
end
...
I thought maybe its the file name because I know android is case sensitive so i changed all the file names to lower case. 我以为可能是文件名,因为我知道android是区分大小写的,所以我将所有文件名都更改为小写。 The images showed so I don't think theres any problem with them but also checked just in case.
图像显示出来,所以我认为它们没有任何问题,但也进行了检查以防万一。 Up to now I don't know what else I could try, any suggestions?
到目前为止,我不知道我还能尝试什么,还有什么建议吗? And I tried removing some codes and found out everything works up until storyboard.gotoScene("correct1", "fade", 1000).
我尝试删除一些代码,发现一切正常,直到storyboard.gotoScene(“ correct1”,“ fade”,1000)。 I can't see any problems with it and even tried to link it to a different scene "results" which is also the same result.
我看不到任何问题,甚至尝试将其链接到另一个场景“结果”,这也是相同的结果。
When faced with such situation, one technique that works well is to add many print statements in the code so that you can find the last line that gets executed. 遇到这种情况时,一种行之有效的技术是在代码中添加许多打印语句,以便您可以找到要执行的最后一行。 Here you have a print statement before the scene goto but unless you have one after, there is no way of knowing if that is where it hangs.
在这里,在场景转到之前有一个打印语句,但是除非后面有一个打印语句,否则无法知道它是否挂在那里。
Once you have done that, you start removing code (comment out) until the problem disappears. 完成此操作后,您将开始删除代码(注释掉),直到问题消失。 The problem is not necessarily the line that hangs;
问题不一定是挂起的线。 it could easily be in the lines prior, even something done at initialization.
它可能很容易就位,甚至可以在初始化时完成。 So you comment out big blocks of code but leave the structure (like all the scene gotos), just comment out things like audio, buttons (except the one required to trigger the goto), etc. When a code removal makes problem disappear, you at least have something to look at (wrong config values, etc).
因此,您注释掉了很大的代码块,但保留了结构(像所有场景一样),仅注释掉了音频,按钮(触发goto所需的按钮除外)等内容。当代码删除使问题消失时,您可以至少要看些东西(错误的配置值等)。
The code above is fine and i cant find any mistake, so upload the other part of the code so that i can check it. 上面的代码很好,我找不到任何错误,因此上传代码的另一部分,以便我可以检查它。 General advice is make sure that your are using the correct file names and the scene names .
一般建议是确保您使用正确的文件名和场景名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.