javascript - how to speed up html5 game - Stack Overflow

Have made a typing game using HTML5 and javascript .NowI wanted to ask a couple of thingsImages loa

Have made a typing game using HTML5 and javascript /. Now I wanted to ask a couple of things

  1. Images load each time the user plays the game. Though I have used img.src to load the image at the beginning.Why is it not loading from cache?
  2. How can I speed up the game in general. The bullet firing mainly.

Code for the game area is here. .html.erb

Thanks!

Rohit Jain

Have made a typing game using HTML5 and javascript http://tweetraitor.herokuapp./. Now I wanted to ask a couple of things

  1. Images load each time the user plays the game. Though I have used img.src to load the image at the beginning.Why is it not loading from cache?
  2. How can I speed up the game in general. The bullet firing mainly.

Code for the game area is here. https://github./rohit-jain/Tweetraitor/blob/master/app/views/guests/play.html.erb

Thanks!

Rohit Jain

Share Improve this question asked Feb 16, 2012 at 18:20 Rohit JainRohit Jain 8313 gold badges12 silver badges22 bronze badges 1
  • The Animation in the background does slow down the game alot, especially if you have a bigger screen – Ibu Commented Feb 16, 2012 at 18:24
Add a ment  | 

2 Answers 2

Reset to default 5

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. 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...

Even simple games like pong (the bouncing ball) are slow even on new devices. The situation is much worse when you try it on underpowered ~100-150 EUR devices from ZTE, Huawei or HTC.

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 (i.e. Sencha touch) or not.

See there also.

Regards, STeN

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745114309a4612037.html

相关推荐

  • javascript - how to speed up html5 game - Stack Overflow

    Have made a typing game using HTML5 and javascript .NowI wanted to ask a couple of thingsImages loa

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信