本文主要是介绍同一个midlet下不同canvas切换实例代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
备份作参考,注意切换时的白屏等问题
public void switchCanvas(int id) {
curCanvasId = id;
if (curCanvasId == 1) {
canvas_1 = new ScreenManager_1();
dataManager = new DataManager_1(null/** this.getAppProperty("MIDlet-Version"* )*/);
dataManager.load();
// reset SPAC system
if (DeviceConstants_1.SPAC_ENABLE) {
SpacFile_1.resetImageCache();
}
// comment this before making iphone build
// canvas_1.setFullScreenMode(true);
Display.getDisplay(this).setCurrent(canvas_1);
gcWait(100);
canvas_1.start();
if (DeviceConstants_1.CALL_SHOW_NOTIFY_ON_STARTAPP)
{
if (canvas_1 != null)
{
canvas_1.showNotify();
}
}
cleanMenuCanvas();
} else if (curCanvasId == 2) {
canvas_2 = new GameCanvas();
Display.getDisplay(this).setCurrent(canvas_2);
gcWait(100);
if (LicenseHandler.LICENSE_HANDLER_SUPPORTED) {
if (canvas_2.isRecurring(this) && !validated
&& canvas_2.validateLicense(this, canvas_2)) {
validated = true;
Display.getDisplay(this).setCurrent(canvas_2);
canvas_2.start();
} else if (!canvas_2.isRecurring(this)) {
Display.getDisplay(this).setCurrent(canvas_2);
canvas_2.start();
}
} else {
canvas_2.start();
}
cleanMenuCanvas();
}
}
这篇关于同一个midlet下不同canvas切换实例代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!