JeZxLee Posted July 17, 2017 Share Posted July 17, 2017 Hi, Simple question: Does current PixiJSv4 have function to detect platform? (like if game is being played on Wndows, Linux, or Android) I want to fill entire screen only on mobile Android and not on desktops/notebooks... Let me know, thanks! JeZxLee Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted July 17, 2017 Author Share Posted July 17, 2017 Hi, I tried this code but it does not detect when game is played on Android? if ( navigator.userAgent.toLowerCase().indexOf('android') > -1 ) Browser = "Android"; else Browser = "Other"; Quote Link to comment Share on other sites More sharing options...
mattstyles Posted July 17, 2017 Share Posted July 17, 2017 Just google it, there are loads of copy-paste scripts out there that will attempt to detect pretty much every common browser/platform out there. Browser/platform detection is pretty rubbish though, try to use feature detection instead. Quote Link to comment Share on other sites More sharing options...
JeZxLee Posted July 17, 2017 Author Share Posted July 17, 2017 Found this on the web: if ( (typeof window.orientation !== "undefined") || ( navigator.userAgent.indexOf('IEMobile') !== -1 ) ) isMobile = true; Worked on my Android phone and tablet. JeZxLee Quote Link to comment Share on other sites More sharing options...
Taz Posted July 17, 2017 Share Posted July 17, 2017 You can try "if (PIXI.utils.isMobile.android.device)" to test for android device and "if (PIXI.utils.isMobile.any)" to test for mobile device using built-in util if want to try that out too. More options at https://github.com/kaimallea/isMobile Quote Link to comment Share on other sites More sharing options...
mattstyles Posted July 18, 2017 Share Posted July 18, 2017 13 hours ago, JeZxLee said: Found this on the web: if ( (typeof window.orientation !== "undefined") || ( navigator.userAgent.indexOf('IEMobile') !== -1 ) ) isMobile = true; Worked on my Android phone and tablet. Yep, platform detection is always one of those things, "it works today", no guarantee it'll work tomorrow and you really don't want to keep a matrix of detection up to date, not to mention that whatever you are expecting on that platform could change (depending on what you want to do of course). See if you can find a library that can handle this, one with enough resources working on it to keep it up to date. Although far better is feature detection, as that is about as future-proof as you get with JS. Quote Link to comment Share on other sites More sharing options...
shashank Posted September 20, 2017 Share Posted September 20, 2017 I have used code below to find device is mobile or not. var ua = window.navigator.userAgent.toLowerCase(); isMobile = ua.indexOf('mobile') !== -1 || ua.indexOf('android') !== -1; Yeferson 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.