Skip to first unread message

Shaun Michael K. Stone

unread,
Aug 26, 2015, 10:31:13 AM8/26/15
to HaxeFlixel
acceleromoter = new FlxAccelerometer();

....

// update method below


#if ACCELERATOR

var deceleration:Float = 1;
var sensitivity:Float = 8.0;
var maxVelocity:Float = 50;

velocityX = acceleromoter.x;
velocityY = acceleromoter.y;

if (velocityX > maxVelocity) {
velocityX = maxVelocity;
} else if (velocityX < -maxVelocity) {
velocityX = -maxVelocity;
}

if (velocityY > maxVelocity) {
velocityY = maxVelocity;
} else if (velocityY < -maxVelocity) {
velocityY = -maxVelocity;
}

this.player.velocity.x = velocityX;
this.player.velocity.y = velocityY;

#end


Can someone help me with moving the player around the screen via the accelerometer. This is what I have so far.

Guilherme Lagemann

unread,
Aug 27, 2015, 9:24:10 AM8/27/15
to HaxeFlixel
Did you take a look in this tutorial? https://www.youtube.com/watch?v=OGL0jrgZGXo
Reply all
Reply to author
Forward
0 new messages