C++ Initialize the J2Play GDK and community wrapper
From J2Play
Initialize the J2Play GDK and community wrapper
Using following code to revise your main window creation process, initializing the J2Play GDK library and community wrapper.
CGDKInstance* j2play = CGDKInstance::GetInstance();
// hGameIcon ! ADDED IN GDK VER 3.1
// hGameIcon is an HICON (Microsoft Windows ICON resouce handle) which will show as the game application icon on the title bar and the task bar
// If you don't have game icon (or you are using GDK VER 3.0 or below), pass in NULL
HWND hwndCommunity = j2play->StartGameCommunity( "Your game name", hGameIcon);
if ( hwndCommunity==NULL // fail to create community window
|| !j2play->ConnectionCheck()) // internet connection failure or J2Play platform server failure
{
j2play->Destroy();
// TODO: You can choose to
// 1) popup some information to user and exit the apllication
// or
// 2) launch your game as an isolated application without J2Play Community
}
else // create game community successfully
{
// TODO: Create your main window using hwndCommunity as the parent window handle,
// and make sure you set the WS_CHILD style instead of WS_OVERLAPPEDWINDOW to your game window
// Notice: If your game uses Direct3D, please create Direct3D device before InsertGameIntoCommunity();
// Insert you game window into the community and
// declare the desired client size.
j2play->InsertGameIntoCommunity( yourGameHwnd, 800, 600 );
if( !j2play->IsAllPassed() ) // login fail
{
j2play->Destroy(); // Destroy GDK to free resource
// TODO: Uninitialize all resource and destroy game window here
return FALSE;
}
RegisterHooks(j2play); // register the event hooks, change it according actual class you used for event receiver
}
MFC: Add above code into InitInstance() of your application class (the class derived from CWinApp), revising the creation process of CMainFrame according to above requests.
WIN32: Revise the main window creation process according to above requests
Offline Mode
Offline mode means your game is runnable without internet connection and J2Play playground support.
For that,
- As above code and comments described, when J2Play community creation fails or internet connection is not available, launching game as an isolated application.
- Change the 'OfflineSupport' flag in [Game] section of J2Play.ini to 1.
