Page 1 of 1

Control Player with Tilt the phone

PostPosted: Sat May 10, 2014 10:36 am
by Behdadsoft
Hi.
I want make a game (Space Invaders) for iPhone and need control spaceship with Crooked ِDevice (Tilt the phone) but I don't know how can do it.

Please Guide Me.

Thanks A Lot.

Re: Control Player with Tilt the phone

PostPosted: Sat May 10, 2014 11:27 am
by Goettsch
hi,
add this code to player-->draw actor

Code: Select all
Vector v = getAccelerometer();
if(v.x>0.2) // moving right
{
    x+=5;
}
else if(v.x<-0.2)
{
    x-=5;
}


this will make your spaceship move left and right

Re: Control Player with Tilt the phone

PostPosted: Fri May 23, 2014 6:40 pm
by Behdadsoft
Thanks Goettsch.

I test it on Android but don't work. :(

Re: Control Player with Tilt the phone

PostPosted: Fri May 23, 2014 6:43 pm
by MrJolteon
Android's not really supported yet. A lot of features are still missing.

Re: Control Player with Tilt the phone

PostPosted: Fri May 23, 2014 7:04 pm
by Behdadsoft
thanks. this feature currently work on iphone?

Re: Control Player with Tilt the phone

PostPosted: Fri May 23, 2014 7:33 pm
by MrJolteon
From what I've read, yes.

Re: Control Player with Tilt the phone

PostPosted: Sat May 24, 2014 4:53 am
by Behdadsoft
Thanks.

MrJolteon +1

Goettsch +1

Re: Control Player with Tilt the phone

PostPosted: Sat May 31, 2014 2:15 am
by Zivouhr
Will keep this option in mind for future games, thanks for posting the tips.