Using Compass (Gyroscope) Sensor at Mobile Targets

82 views
Skip to first unread message

Gokhan

unread,
Jul 9, 2014, 4:15:30 AM7/9/14
to haxef...@googlegroups.com
Hello,

I would like to use gyro sensor for my mobile game. But I couldn't find it in API. Is it possible to use it with HaxeFlixel? How can I do it?

Thanks in advance.

Gama11

unread,
Jul 9, 2014, 4:38:54 AM7/9/14
to haxef...@googlegroups.com
There's FlxG.accelerometer for it. You can find a demo here.

Gokhan

unread,
Jul 9, 2014, 6:40:40 AM7/9/14
to haxef...@googlegroups.com
Thank you, it seems to do the job.

Now I try to implement it but I had an error on compiling, saying:
flixel.Class<FlxG> has no field accelerometer

I have imported:
import flixel.FlxG;
import openfl.sensors.Accelerometer;

FlashDevelop auto-completes FlxG.accelerometer but still I have this error. What can cause this?


9 Temmuz 2014 Çarşamba 11:38:54 UTC+3 tarihinde Gama11 yazdı:

Gama11

unread,
Jul 9, 2014, 6:41:47 AM7/9/14
to haxef...@googlegroups.com
FlxG.accelerometer is only available on mobile targets, you need to use #if mobile conditionals.
Reply all
Reply to author
Forward
0 new messages