0
我正在使用Mosync API C++進行跨平臺移動開發。我試圖讓透明屏幕(其中有一個不透明的標籤)在另一個屏幕上顯示,這樣我就可以同時看到兩個屏幕。Mosync:在另一個屏幕上顯示透明屏幕
但是它發生了什麼,它的屏幕不透明,它的黑色?爲什麼會發生?我知道它可能做到這一點,因爲菜單的Sams CookBook示例是一個透明屏幕(帶有列表框)&它顯示在另一個屏幕的頂部。
爲什麼你認爲我的下面的代碼不顯示透明屏幕而是黑屏?我的小項目,例如附後(包括它的透明PNG文件):
#include <MAUtil/Moblet.h>
#include <MAUI/Screen.h>
#include <MAUI/Label.h>
#include <MAUI/Image.h>
using namespace MAUtil;
using namespace MAUI;
#define RES_BLANK 1
class ClearScreen : public Screen
{
public:
ClearScreen() : Screen()
{
Image *cell = new Image(0, 0, 400, 800, NULL, true, true, RES_BLANK);
Label *item = new Label(10, 300, 200, 200, cell);
// What SHOULD happen: have the whole screen transparent by having a
// transparent Image as the background & have a pink label on this screen,
// Then I should be able to also see parts of MyScreen behind this screen
// because parts of this are transparent
// What ACTUALLY happens:
// This creates an Image that is black (that covers the whole screen)
// & a pink label on it
this -> setMain(cell);
}
private:
};
class MyScreen : public Screen
{
public:
MyScreen() : Screen()
{
Label *cell = new Label(0, 0, 400, 800, NULL);
Label *item = new Label(0, 0, 200, 200, cell);
cell -> setDrawBackground(true);
cell -> setBackgroundColor(20000);
item -> setDrawBackground(true);
item -> setBackgroundColor(90000);
this -> setMain(cell);
}
private:
};
class MyMoblet : public Moblet
{
public:
MyMoblet()
{
MyScreen *m = new MyScreen();
m -> show();
ClearScreen *c = new ClearScreen();
c -> show();
}
void keyPressEvent(int keyCode, int nativeCode)
{
}
void keyReleaseEvent(int keyCode, int nativeCode)
{
}
};
extern "C" int MAMain()
{
Moblet::run(new MyMoblet());
return 0;
};