Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

8 years ago by ComitOne

I'm trying to move a cursor tile like a pointer using ig.input.accel x/y info i'm getting back from Siri remote's accelerometer. I can successfully get the cursor to move smoothly in the direction I'm pointing the remote in, but movement is slow an not 1:1 between my hand movement and cursor position on screen. Here's what I have so far:


cursor: null,
cursorX: 0.0,
cursorY: 0.0,

init: function( ) {

        this.cursor = new tpf.HudTile( this.cursorImage, 0, 128, 128 );

        // Start with cursor centered
        this.cursorX = ig.system.width / 2
        this.cursorY = ig.system.height / 2
},

draw: function(  ) {
        
         this.cursor.draw()

         if( ig.input.accel ) {
                 this.cursorX += (ig.input.accel.x);
                 this.cursorY += (ig.input.accel.y);
                 this.crosshair.setPosition( this.crosshairX, this.crosshairY);
          }
}


Can anyone help?

8 years ago by Joncom

Multiply to move it faster.

var speed = 4; // 4 times faster
this.cursorX += (ig.input.accel.x) * speed;
this.cursorY += (ig.input.accel.y) * speed;
Page 1 of 1
« first « previous next › last »