[英]how to speed up html5 game
Have made a typing game using HTML5 and javascript http://tweetraitor.herokuapp.com/ . 使用HTML5和javascript http://tweetraitor.herokuapp.com/制作了打字游戏。 Now I wanted to ask a couple of things 现在我想问几件事
Code for the game area is here. 游戏区的代码在这里。 https://github.com/rohit-jain/Tweetraitor/blob/master/app/views/guests/play.html.erb https://github.com/rohit-jain/Tweetraitor/blob/master/app/views/guests/play.html.erb
Thanks! 谢谢!
Rohit Jain 罗希特·贾恩(Rohit Jain)
I can tell you for the first part of the question that you may want to try to cache the images in base64 into the localstorage of the user. 对于问题的第一部分,我可以告诉您,您可能希望尝试将base64中的图像缓存到用户的本地存储中。 This way, the data will already be loaded client side and won't require the client to download everything. 这样,数据将已经在客户端加载,并且不需要客户端下载所有内容。
Here is a blog post about how to do it . 这是有关如何执行此操作的博客文章 。 In short, you have to check if the image is in the local storage 简而言之,您必须检查映像是否在本地存储中
if ( localStorage.getItem('myImageId')) {
if not to save it into it 如果不保存到里面
localStorage.setItem('myImageId',image);
our general experience with HTML5/JavaScript/CSS based games on Android is that it is very slow - we have games we are using across platforms (desktop, TVs, iPhone) but for the Android we rewrite them natively in Java... 我们在Android上使用基于HTML5 / JavaScript / CSS的游戏的一般经验是,它非常慢-我们拥有跨平台(台式机,电视,iPhone)使用的游戏,但对于Android,我们使用Java原生重写了这些游戏...
Even simple games like pong (the bouncing ball) are slow even on new devices. 甚至在新设备上,诸如pong(弹跳球)之类的简单游戏也很慢。 The situation is much worse when you try it on underpowered ~100-150 EUR devices from ZTE, Huawei or HTC. 当您在中兴通讯,华为或HTC功率不足的100-150欧元设备上尝试此情况时,情况会更糟。
If you will find out some general solution we will be more then happy to use it, but i doubt there is any. 如果您能找到一些通用的解决方案,我们将很乐意使用它,但我怀疑是否有任何解决方案。 Does not matter if you are using some framework (ie Sencha touch) or not. 是否使用某些框架(即Sencha touch)无关紧要。
Regards, STeN 问候,STeN
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.