Jump to content

Intel XDK Lag


CharlesCraft50
 Share

Recommended Posts

I'm facing some kind of issues, when the player moving or in the air or falling in the air, the game will lag in mobile (not on desktop)
Code:
 

if(cursors.left) {
        player.body.velocity.x = -200;

        if(player.facing != 'left') {
            player.scale.x = 1;
            player.animations.play('walk');
            player.facing = 'left';
        }
      } else if(cursors.right) {
        player.body.velocity.x = 200;

        if(player.facing != 'right') {
            player.scale.x = -1;
            player.animations.play('walk');
            player.facing = 'right';
        }
      } else {
        player.body.velocity.x = 0;

        if(player.facing != 'idle') {
            player.animations.stop();

            if(player.facing == 'left') {
                if(player.holding != 'nothing' && player.holding != 'powerUp_2x') {
                  player.scale.x = 1;
                  player.animations.stop();
                  player.frame = 10;
                } else {
                  //Jump animation:
                  if(this.jumping == true) {
                  player.frame = 13;
                  player.scale.x = 1;
                  //break;
                  } else {
                  //Player idle left
                  player.scale.x = 1;
                  player.animations.stop(null, true);
                  //break;
                  }
                }
            } else {
                if(player.holding != 'nothing' && player.holding != 'powerUp_2x') {
                  player.scale.x = -1;
                  player.animations.stop();
                  player.frame = 10;
                } else {
                  //Jump animation:
                  if(this.jumping == true) {
                  player.frame = 13;
                  player.scale.x = -1;
                  //break;
                  } else {
                  //Player idle left
                  player.scale.x = -1;
                  player.animations.stop(null, true);
                  //break;
                  }                }
            }

            player.facing = player.facing;
        }
      }


      if(player.body.onFloor()) {
          this.jumps = 0;
          this.jumping = false;
      }

      if(cursors.up && this.jumps < 5) {
          player.body.velocity.y = -1000;
          this.jumps++; 
          this.jumping = true;
      }

      if(cursors.down) {
          if(player.facing == 'left') {
            player.scale.x = 1;
          } else {
            player.scale.x = -1;
          }
            player.frame = 4;
            player.body.velocity.x = 0;
      }

 

Link to comment
Share on other sites

There doesn't appear to be any code posted above relating to Intel XDK or Cordova etc - why do you think the issue is XDK related?  How does the same game play in-browser on the same mobile device?

Perhaps the issue you are facing is non-apparent on desktop due to increased performance - for example update loops using a deltaTime, which is very small on the more powerful desktop, but larger on the less performant mobile to the extent of observable lag.  But I am speculating.  To avoid guesswork add runtime debug output for you to measure what's really happening on any give device - add functionality incrementally and zoom into any area that effects performance.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...