Platform Utilities
Overview
Platform utilities provide a set of functions for detecting device capabilities, screen properties, and platform-specific features. These utilities are essential for creating responsive and platform-optimized games.
Display Detection
Retina Display
Detect high-DPI (Retina) displays:
Input Detection
Touch Support
Check if the device supports touch input:
Device Detection
Mobile Devices
Check if the user is on a mobile device:
Specific Platforms
Detect specific mobile platforms:
Common Use Cases
Responsive Game Design
Input Management
Platform-Specific Features
Best Practices
- Use platform detection for initial setup rather than continuous checks
- Cache detection results rather than checking repeatedly
- Combine multiple checks for comprehensive device profiling
- Consider progressive enhancement based on device capabilities
- Test on various devices and platforms to ensure proper detection
Performance Considerations
When using platform detection:
- Cache detection results at startup:
- Use the cached values throughout your game: