Okay, I have my game 99.999% done, fully converted and working in Tier 2.
I had it successfully working in Windows and iOS (iPod Touch, iPad2).
So, time to get it working in the Android world. And, after some issue that I don't know what it was but I managed to make it disappear, I got it compiling and working (almost) on my Android devices.
These are my Android test devices:
1. Toshiba Thrive 7", Android version 3.2.1 Honeycomb
2. VIZIO VTAB1008, Android version 3.2.1 HTK55
3. Nexus 7, Android version 4.1.1 Jelly Bean
They all happily loaded and looked correct, but did not quite play correctly.
The Toshiba played fine, but the orientation (based on which side the top is tilted to) is the reverse of how it plays on the iOS devices (I've posted how to fix the misunderstanding between AppGameKit and iOS about which side the home button is on for orientations 3 and 4). But that doesn't worry me at all, as long as it sticks with one orientation and doesn't flip (which it doesn't).
The Nexus and Vizio show the same orientation as the iOS devices. However the actual values returned by the accelerometer while in orientation 3 are not correct.
So, I decided to run an app to show what was reported for the orientations.
I created both a Tier 1 and a Tier 2 version.
Here is the Tier 1 code (very simple):
// set up the display a bit
SetDisplayAspect(-1)
SetOrientationAllowed(1,1,1,1)
SetTransitionMode(0)
//SetSyncRate(5.0,1)
// main loop
do
// check for done
if getPointerPressed()=1 then exit
// print information on screen
Print("Tier 1 Orientation Test")
Print("GetOrientation="+str(GetOrientation()))
Print("GetDeviceWidth="+str(GetDeviceWidth()))
Print("GetDeviceHeight="+str(GetDeviceHeight()))
Print("GetVirtualWidth="+str(GetVirtualWidth()))
Print("GetVirtualHeight="+str(GetVirtualHeight()))
Print("GetDirectionX="+str(GetDirectionX(),2))
Print("GetDirectionY="+str(GetDirectionY(),2))
Print("GetDirectionAngle="+str(GetDirectionAngle(),2))
Print("GetDisplayAspect="+str(GetDisplayAspect(),2))
Print("Touch anywhere to exit")
// update the screen
Sync()
loop
end
Here is the template.h file (you can see I have it set up for multiple platforms):
#ifndef _H_APP
#define _H_APP
// Link to AGK libraries
#include "agk.h"
// Global values for the app
class app
{
public:
// main vars
#ifdef IDE_XCODE
static bool did_start;
#endif
public:
// constructor
app() {memset (this, 0, sizeof(app));}
// main app functions
void Begin( void );
void Loop( void );
void End( void );
#ifdef IDE_XCODE
void appGetResumed( void );
#endif
private:
void closeThisApp();
};
extern app App;
#endif
// Allow us to use the LoadImage function name
#ifdef LoadImage
#undef LoadImage
#endif
And template.cpp:
// Includes, namespace and prototypes
#include "template.h"
using namespace AGK;
app App;
#ifdef IDE_ANDROID
extern void exit(int);
#endif
#ifdef IDE_XCODE
// globals
bool app::did_start = false;
#endif
// Begin app, called once at the start
void app::Begin( void )
{
// set up the display a bit
agk::SetDisplayAspect(-1);
// allow all orientations
agk::SetOrientationAllowed(1,1,1,1);
agk::SetTransitionMode(0);
}
// Main loop, called every frame
void app::Loop ( void )
{
#ifdef IDE_XCODE
// indicate started
app::did_start = true;
#endif
if (agk::GetPointerPressed()) closeThisApp();
agk::Print("Tier 2 Orientation Test");
agk::PrintC("GetOrientation=");
agk::Print(agk::GetOrientation());
agk::PrintC("GetDeviceWidth=");
agk::Print(agk::GetDeviceWidth());
agk::PrintC("GetDeviceHeight=");
agk::Print(agk::GetDeviceHeight());
agk::PrintC("GetVirtualWidth=");
agk::Print(agk::GetVirtualWidth());
agk::PrintC("GetVirtualHeight=");
agk::Print(agk::GetVirtualHeight());
agk::PrintC("GetDisplayAspect=");
agk::Print(agk::GetDisplayAspect());
agk::PrintC("GetDirectionX=");
agk::Print(agk::GetDirectionX());
agk::PrintC("GetDirectionY=");
agk::Print(agk::GetDirectionY());
agk::Print("Touch anywhere to exit");
agk::Sync();
}
// Called when the app ends
void app::End ( void )
{
}
#ifdef IDE_XCODE
// Called when the app returns from being in the background
void app::appGetResumed( void )
{
// do anything that needs to be handled after being paused
}
#endif
void app::closeThisApp()
{
// completely exit the app
#ifdef AGKWINDOWS
PostQuitMessage(0);
#endif
#ifdef IDE_ANDROID
// similar to iOS, an exit button should not be done
// but for this app, we'll do it
exit(1);
#endif
#ifdef AGKIOS
// forcing a quit in iOS is against recommended guidelines - use HOME button
// the exit button is disabled on AGKIOS builds
#endif
#ifdef IDE_MEEGO
g_appptr->quit();
#endif
#ifdef IDE_MAC
glfwCloseWindow();
#endif
#ifdef IDE_BADA
// Bada platform has a HOME button to quit apps
#endif
}
(See post
http://forum.thegamecreators.com/?m=forum_view&t=198533&b=44 for an explanation about appGetResumed and how it is used.)
Pretty straight forward. I built the apps first in Windows, which worked of course without actually allowing me to rotate the app.
Then I made Tier 1 and Tier 2 projects in both Xcode and Android, all using exactly the same code listed above.
On the iOS devices, both Tier 1 and Tier 2 reported the same things and adjusted orientations as expected.
The Android apps behaved quite differently, between Tiers and devices.
These are the orientation definitions as they are working on my iOS devices:
AGK Orientation 1 - iOS Portrait with home button on bottom (Xcode - Portrait)
AGK Orientation 2 - iOS Portrait with home button on top (Xcode - Upside Down)
AGK Orientation 3 - iOS Landscape with home button on right (Xcode - Landscape Right)
AGK Orientation 4 - iOS Landscape with home button on left (Xcode - Landscape Left)
(It was these last two that were causing a problem on iOS until I figured out the fix, see post
http://forum.thegamecreators.com/?m=forum_view&t=198994&b=44.)
This table will show what happened on each device and tier, the numbers are the AppGameKit orientations:
Toshiba Thrive 7":
Tier 1 Tier 2
Held In 1 2 3 4 1 2 3 4
Reported 2 1 4 3 2 1 4 3
Vizio VTAB1008:
Tier 1 Tier 2
Held In 1 2 3 4 1 2 3 4
Reported 1 x 3 x 3 4 2 1
Tier 1 would not change to the other two orientations at all, nor would it report any change.
Tier 2 would not visibly change to orientations 2 and 4, but it would report a changed
orientation, even if it was the wrong one
Nexus 7:
Held In 1 2 3 4 1 2 3 4
Reported 1 2 3 4 3 4 2 1
Okay, we have a native usage issue again.
Comparing the Core.cpp files, there is a section in the Tier 1 file that was commented and set as OLD that still exists in the Tier 2 file.
So, the native stuff does not appear to be being used in the Tier 2 Android stuff.
Cheers,
Ancient Lady
AGK Community Tester