1

I am a student who is studying webview on android. as I am a foreigner, I will thank you if you consider my mistakes on grammer...

I encountered a problem on making webview. it is its "performance" when I use timer(setInterval method).

I am making a shooting game which is like "1945 strikers". I made a effect which shows explosion-images using "Timer"(setInterval). (This effect shows 14-pictures in order rapidly)

but, the problem is that my mobile phone can not show that effect naturally. (it is stopped little by little)

I can not understand what is wrong. exactly, I reduced "new" methods by using "pop" and turned off sounds.

I guess that the problem is based on the number of timer. In my game, each bullet which hitted enemy occur explosion Timer. and I duplicated this Timer to 10 as I thought it was not enough.

source code is like this.

=====call animation=======================

function drawCrash(x,y){

    if (crashCount1 == 0) {
        crashHereX = x; 
        crashHereY = y;
        crashTimer1 = window.setInterval(crashAnimation1, interval);
        crashCount1++;
    }
    else if (crashCount2 == 0) {
        crashHereX2 = x;
        crashHereY2 = y;
        crashTimer2 = window.setInterval(crashAnimation2, interval);
        crashCount2++;
    } 

... (total 10 methods)

======explosion animation==========================

function crashAnimation1() {

    this.crashList=[crash01,crash02,crash03,crash04,crash05,
                   crash06,crash07,crash08,crash09,crash10,
                   crash11,crash12,crash13,crash14];    

    if (crashCount1 >= 13) {
        window.clearInterval(crashTimer1);
        crashCount1 = 0;
    } else {
        crashCount1+=1;
    }
    this.context.drawImage(this.crashList[crashCount1],crashHereX,crashHereY,50,50);
}


function crashAnimation2() {

    this.crashList=[crash01,crash02,crash03,crash04,crash05,
                   crash06,crash07,crash08,crash09,crash10,
                   crash11,crash12,crash13,crash14];    

    if (crashCount2 >= 13) {
        window.clearInterval(crashTimer2);
        crashCount2 = 0;
    } else {
        crashCount2+=1;
    }
    this.context.drawImage(this.crashList[crashCount2],crashHereX2,crashHereY2,50,50);
}

... (total 10 methods)

is there anything which makes my game slow?

I have been debugging my source code using Chrome,(using F12 key) but my laptop computer performs my source code well. there isn't any problem!

you must hard to understand what I am saying...

what I want to know are like this.

  1. should I reduce setInterval method to show the game performance naturally? but, previous version (android 4.1.2) had NO problem! it performed naturally! Now, I am using kitkat version(4.4.2)... I really hate this version. Even I tried to downgrade my android phone! it was hard for me to find "e.preventDefault();" it took 3-days for me to find...

  2. is there anything which is better to debug JavaScript?(I am using Chrome F12 key)

  3. is the "splice(index,1);" method occur "stopped phenomenon"(which I said above, "not natural") when it is used many time? (in my game, many bullets are created and removed(new and splice))

I really want to know how to solve this problem... Thank you very much.

Jnsu Lee
  • 11
  • 2
  • http://stackoverflow.com/questions/21725969/webview-difference-in-android-4-3-to-4-4 – xd6_ Jul 20 '14 at 14:07

0 Answers0