[r174]Ambient light doesn't trigger on Windows Phone 8.1

0 favourites
  • 4 posts
From the Asset Store
Game Triggers
$44.50 USD
50% off
Game Triggers is as versatile as a Swiss army knife, and will be a great resource for any type of game you're creating.
  • Problem Description

    The ambient light sensor (lux) on Windows Phone 8.1 doesn't work correctly

    Attach a Capx

    You can try with the default light-sensor example, anyway here a copy of the capx https://www.dropbox.com/s/p30met8ab27lj ... Light.capx

    Description of Capx

    The Ambient light variable doesn't update. So i can't get the current state of ambient-light or lux value

    Steps to Reproduce Bug

    • Export to windows phone WinJS universal app (8.1)
    • Run application on a Windows Phone 8.1 with lux capability (es: lumia 925)
    • Look the value : it doesn't change.

    Observed Result

    The variable is setted on start, but not continously

    Expected Result

    The "readingchanged" JS events fire the construct 2 event.

    Affected Browsers

    • Internet Explorer (Windows Phone 8.1): (YES)

    Operating System and Service Pack

    Windows Phone 8.1 (8.0 doesn't support lux)

    Construct 2 Version ID

    Construct 2 r174 personal edition

    I Debug a little in the visual studio project and i checked the fragment "responsible" of light relevation

    if (this.runtime.isWinJS && !this.runtime.isWindows8Capable)
    		{
    			var lightSensor = Windows["Devices"]["Sensors"]["LightSensor"]["getDefault"]();
    			if (lightSensor)
    			{
    				var minInterval = lightSensor["minimumReportInterval"];
    				lightSensor["reportInterval"] = (minInterval > 16 ? minInterval : 16);
    				lightSensor.addEventListener("readingchanged", function (e)
    				{
    					ambientlux = e["reading"]["illuminanceInLux"];
    					self.runtime.trigger(cr.plugins_.UserMedia.prototype.cnds.OnDeviceLight, self);
    				});
    			}
    		}
    [/code:s4ssrvtw]
    
    If i make a breakpoint into the event listener body (self.runtime.trigger(cr.plugins_.UserMedia.prototype.cnds.OnDeviceLight, self);) I verified that the event is raised only a few times...
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I open this example and i dont know what is this ambient light please explain me ?

  • Ambient light check light sensor of your camera/phone... it's a feature of User Media plugin https://www.scirra.com/manual/144/user-media

  • It works on a Nokia Lumia 520, but as you say the event stops firing after about 10 seconds. As you also noticed it is because Windows Phone itself is not firing the "readingchanged" event any more. This is to do with Windows Phone, not Construct 2 - the fact it works for at least a few seconds shows our code is working. You may want to report this to Microsoft. Closing as not a C2 bug.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)