Sign in to follow this  
bexphones

how to have a beautiful shake effect with gyro.js and physics ?

Recommended Posts

Hi,

I would like shake my phone to see my objects collide to the bounds of my phone. i success but the effect doesn't look great. I must rotate my phone to see this effect. What i want is only shake my phone and obtain the same result. What must i do to have this ? Thanks.

here my snippet :


		game.world.setBounds(0,0,1400,1750)

		o.lot_of_roll = game.add.spriteBatch();

		var stars = [];

		for (var i = 0; i < data.number_rolls_players; i++){
			o.rolls = game.add.sprite(random(200,w-550),random(400,h),'roll_rank') 
			game.physics.enable( [ o.rolls ], Phaser.Physics.ARCADE);
			o.rolls.body.collideWorldBounds = true;
			o.rolls.body.bounce.y = 0.8;
			o.rolls.body.gravity.y = 900;
			o.rolls.body.allowGravity = true;
			o.lot_of_roll.addChild(o.rolls);
			stars.push(o.rolls);
		}
		gyro.frequency = 10;
		gyro.startTracking(function(trac){
			for (var i = 0; i < data.number_rolls_players; i++){
				o.lot_of_roll.children[i].body.velocity.x += trac.gamma*10;
				o.lot_of_roll.children[i].body.velocity.y += trac.beta*10;
			}
		});		

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.