SDK 6.3/C++/Application
SDK 6.3 · PAWN API: Core ·
Graphics ·
Topology ·
Sound ·
Motion Sensor ·
Leaderboard ·
Splash Screen ·
Physics ·
Network ·
Save ·
Scramble ·
Logging
C++: Native API · Application · GFX Engine · Rust: Rust API (experimental) · Changelog
← SDK 6.3 · C++ / Application framework
Every C++ cubeapp subclasses Cubios::Application and registers it in the OnInit() entry point via AppManager::SetApplication(). The same source runs on all eight modules; use Module / IsMasterModule() to branch per module.
Entry point
// Application initialization callback. Called once when the cubeapp starts
void OnInit(Cubios::AppManager& appMgr)
{
appMgr.SetApplication(new MyGame);
}
class Cubios::Application
Callbacks to override:
virtual void on_Message(uint32_t type, uint8_t *pkt, u32_t size) = 0;- Called when the module receives an inter-module network packet.
virtual void on_ExternalMessage(uint8_t *pkt, u32_t size) = 0;- Called when the module receives external data over BLE from the companion app.
virtual void on_PhysicsTick(const std::array<Screen, 3> &screens) = 0;- The "physics" callback; called recurrently with at least 33 ms resolution (or less, depending on load).
virtual void on_Tick(uint32_t time, uint32_t dt) = 0;- Called every tick of the cubeapp application loop with current time and delta.
virtual void on_Render(std::array<Screen, 3> &screens) = 0;- Called every time the device is about to render visuals; iterate the three
Screens and draw.
virtual void on_Twist(const TOPOLOGY_twistInfo_t &twist) = 0;- Called when the cube is twisted and its topological description has changed.
virtual void on_Tap(uint32_t count);- Called on a tap on one of the module's screens.
virtual void on_Pat(uint32_t count);- Called on a pat (tap on the opposite side).
virtual void on_Close();- Called before the application is closed.
virtual void on_Timer(uint8_t timerID);- Called when a programmable timer (see
SetTimer()) fires.
Services provided:
uint32_t GetTime() const; uint32_t GetTimeSeconds() const; void SendNetworkMessage(uint32_t type, NetworkMessage *msg) const; void SendExternalMessage(uint32_t type, uint8_t *data, size_t size) const; void SaveState(void *data, size_t size) const; i32_t LoadState(u32_t *id, void *data, size_t size) const; void SaveState(SaveMessage* msg) const; i32_t LoadState(u32_t *id, SaveMessage* msg) const; bool SetTimer(uint8_t id, uint32_t delay, bool suspended = false); bool StartTimer(uint8_t id); bool StopTimer(uint8_t id); void KillTimer(uint8_t id); void ShowFPSCounter(bool b); bool IsMasterModule(); if (this->Module == 0) return true; inline int GetImageAssetsCount(); inline int GetSoundAssetsCount();
Public fields: Cubios::Scene Scene; — the module's scene graph; uint32_t Module; — index (0–7) of the module running this instance.
class Cubios::AppManager
The manager pumps the event loop: network packets → on_Message, BLE data → on_ExternalMessage, twists → on_Twist, taps/pats, timers, ticks and rendering.
struct Timer_t
struct Timer_t { bool suspended; uint32_t delay; uint32_t time; uint8_t id; };