Jump to content

Object Velocity issue on different devices


traxtrack
 Share

Recommended Posts

Hey, 

So I am working on a car game and I have 1 issue with the speed at which car drops. 
My friend who owns a IPhone s6 complains that on his device the cars drop too fast, while on my Samsung s7 edge the car seems to drop slow enough. 
I dont know what might cause it.

My obstacle velocity is set to 1200;

// OBSTACLES vars
var obstacleSpeed = 1200;
var obstacleDelay = 400;
var platforms;
var score;

 

And this is my Loop + update function 
 

  	// OBSTACLES OF THE CAR
  	game.time.events.loop(obstacleDelay, function(){
      var obstacleSpeed = 1200;
      var obstacleDelay = 400;
  		 for(var i = 0; i < 1; i++){
  				if(game.rnd.between(0, 1) == 1){
  				 var obstacle = new Obstacle(game, i);
           obstacle.scale.setTo(scaleRatio, scaleRatio);
  				 game.add.existing(obstacle);
  				 obstacleGroup.add(obstacle);
  				}
  		 }
  	});

    // Game on touch move car
  	game.input.onTap.add(function() {
  		if (game.input.x < w / 2 ){
  			if( canMove && goleftonce == 2 || goleftonce == 1) {
  				canMove = false;
          goleftonce++;
          gorightonce--;
  				game.add.tween(car).to({ angle: -30}, 100, Phaser.Easing.Linear.None, true).onComplete.addOnce(function(){ game.add.tween(car).to({ angle: 0}, 100, Phaser.Easing.Linear.None, true); canMove = true; }, this);
  				game.add.tween(car).to({x: car.x - w/3}, 100, Phaser.Easing.Linear.None, true);
  			}
  		}
  		else {
        if( canMove && gorightonce == 2 || gorightonce == 1) {
  				canMove = false;
          goleftonce--;
          gorightonce++;
  				game.add.tween(car).to({ angle: 30}, 100, Phaser.Easing.Linear.None, true).onComplete.addOnce(function(){ game.add.tween(car).to({ angle: 0}, 100, Phaser.Easing.Linear.None, true); canMove = true; }, this);
  				game.add.tween(car).to({x: car.x + w/3}, 100, Phaser.Easing.Linear.None, true);
  			}
  		}
  	});
  },
    update: function() {
      //  Collide the car and with the obstacles aka other cars
      game.physics.arcade.collide(car, obstacleGroup, function(){
        canMove = true;
      	countcars = 0;
        goleftonce = 2;
        gorightonce = 2;

        game.state.start('gameover');
      });
    }
}



  // Position where the obstacle spawns
  Obstacle = function (game) {
   	var position = game.rnd.between(0, 2);
  	Phaser.Sprite.call(this, game, (w/3) * position + 130 , 0, "obstacle");
  	game.physics.enable(this, Phaser.Physics.ARCADE);
  };

  Obstacle.prototype = Object.create(Phaser.Sprite.prototype);
  Obstacle.prototype.constructor = Obstacle;

  Obstacle.prototype.update = function() {
  this.body.velocity.y = obstacleSpeed;
    if(this.y > game.height){
    	countcars++;
    	score.setText("Score: " + countcars);
    	this.destroy();
    }
  };


 

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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