Skip to main content

Application Development

Design Guidelines


UI Design Principles

  • Adapt to 640x480 resolution

Color Guidelines

Typography

  • System Fonts: Silkscreen
  • Recommended Font Sizes: 46 36 28 24 20

Icon Design

  • Dimensions: 48x48dp, 72x72dp, 96x96dp
  • Style: Flat,minimalist

Physical Button Development


BitBoy OS Button Mapping Tools

BitBoy OS SDK provides two core classes for handling physical button mapping: KeyEventHelper and KeyEventActivity.

KeyEventHelper

For handling buttons in specific Views:

val keyEventHelper =  KeyEventHelper(
onPress = { code, view -> /* Handle press */ },
onLongPress = { code, view -> /* Handle long press */ },
KEY_A, KEY_X, KEY_Y
)
yourView.setOnKeyListener(keyEventHelper)

KeyEventActivity

Base class for global button handling:

class  YourActivity : KeyEventActivity() {
override fun onKeyA() { /* A button press */ }
override fun onLongKeyA() { /* A button long press */ }
// Other button methods...
}

Key Features

  • Supports press and long-press events
  • Predefined common button codes (A, B, X, Y, etc.)
  • Day/Night mode switching support
  • Customizable button responses
important
  • Default long-press duration is 300ms
  • Clear button states in onPause
  • Some buttons (like HOME) are disabled by default

Key Mapping

ButtonKeyCodeDescription
AKEY_A / KEY_GAME_AConfirm / Start
BKEY_B / KEY_GAME_BCancel / Back
XKEY_XFunction 1
YKEY_YFunction 2
UpKeyEvent.KEYCODE_DPAD_UPUp
DownKeyEvent.KEYCODE_DPAD_DOWNDown
LeftKeyEvent.KEYCODE_DPAD_LEFTLeft
RightKeyEvent.KEYCODE_DPAD_RIGHTRight
LKEY_BACK_LEFTLeft shoulder button
RKEY_BACK_RIGHTRight shoulder button
StartKEY_STARTStart (same as A button)
SelectKEY_SELECTSelect
Center buttonKEY_MID_FCenter button (same as B button)

Performance Optimization Guidelines

When developing games within the BitBoy OS ecosystem, performance optimization is crucial for ensuring a smooth user experience. Here are optimization recommendations for several key areas:

Graphics Optimization

First, enabling hardware acceleration can significantly improve graphics rendering efficiency, reducing CPU load and enhancing overall performance. Meanwhile, it's important to minimize the use of transparency effects, as excessive transparency layers increase drawing complexity and affect rendering speed. Optimizing drawing hierarchy is also crucial; simplifying view hierarchy and reducing unnecessary nesting levels can further improve rendering performance. Additionally, proper use of image compression and caching techniques can reduce memory usage and loading times, ensuring smooth graphical performance.

Memory Management

Effective memory management is essential for maintaining application stability and responsiveness. We recommend using SparseArray instead of HashMap, as SparseArray is more efficient when handling large amounts of data and reduces memory consumption. Additionally, promptly releasing unused resources prevents memory leaks. For example, disposing of bitmaps and other large objects when no longer needed ensures timely memory recycling. Furthermore, following good programming practices and avoiding unnecessary references can effectively prevent memory leaks and improve overall application performance.

Battery Optimization

To extend device battery life, it's important to manage background tasks and network requests efficiently. Using JobScheduler for background task scheduling not only optimizes resource usage but also reduces power consumption. Reducing the frequency of network requests is also crucial; try to combine requests or implement data caching strategies to minimize the impact of network activity on battery life. Moreover, optimizing Wake Lock usage by ensuring devices are kept awake only when necessary can significantly reduce unnecessary power consumption and improve user battery life experience.

Debugging and Testing

During development, utilizing tools for performance analysis and debugging is an essential step in ensuring efficient application operation. Android Profiler can be used for real-time performance monitoring, helping identify and resolve performance bottlenecks. LeakCanary is a powerful memory leak detection tool that automatically captures and reports memory leak issues, ensuring application memory usage remains within reasonable bounds. Additionally, Firebase Performance Monitoring provides comprehensive performance data analysis, helping developers understand application behavior in different environments and implement targeted optimizations. By combining these tools, developers can comprehensively improve application stability and performance.

Furthermore, it's recommended to conduct regular performance testing throughout development, simulating different usage scenarios and device environments to ensure consistent application performance across various conditions. Optimizing code structure and adopting efficient algorithms and data processing methods are also effective ways to enhance performance. Through systematic and continuous optimization measures, developers can create an efficient and stable blockchain gaming ecosystem that provides users with an exceptional gaming experience.