KevinnFtw

Change angle of sprite based on accelerometer

Recommended Posts

Hi,

 

It's my first time using the Phaser.io and I must say it is great so far.

I've ran into a problem, I want to create a webbased game that you can play on a mobile device using the accelerometer.

 

What I want to do is change the angle of a sprite based on the x and y value of the accelerometer.

Problem is, I don't know how to do this at all. 

 

I'm using the gyro.js library to get the tracking values. At the moment I'm using this code in my create() function to move the sprite on the screen (but it doesn't rotate accordingly):

if(gyro.getFeatures().length > 0) {     gyro.frequency = 10;     gyro.startTracking(function(o) {     player.body.velocity.x += o.x;     player.body.velocity.y += o.y;     });}
 
Can anyone tell me how I could accomplish this?

Share this post


Link to post
Share on other sites

Would be interested to know how you get on with this.

I'd love to keep you updated. The game is just in the beginning stage, but still got 10 weeks to develop 'something' which will hopefully be a fully working game.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.