简体   繁体   English

Printf擦除屏幕(使用MoSync库)

[英]Printf erases the screen (using the MoSync library)

I have some simple code that looks like this: 我有一些简单的代码如下所示:

printf("Press zero or back to exit\n");
maSetColor(0x0055ff);
maFillRect(10,10,100,100);
maUpdateScreen();

This runs, but when it's like this: 这会运行,但是就像这样:

maSetColor(0x0055ff);
maFillRect(10,10,100,100);
maUpdateScreen();
printf("Press zero or back to exit\n");

printf erases the screen. printf删除屏幕。

Why is this? 为什么是这样? Is this a normal property of printf() ? 这是printf()的正常属性吗? Is there a different print function I should use to print on top of everything, instead of erasing everything? 我应该使用其他打印功能在所有内容上进行打印,而不是擦除所有内容吗? I know I can use MoSync's MaDrawText() instead, but I was wondering if there was a print function that would also work. 我知道我可以改用MoSync的MaDrawText() ,但是我想知道是否有一个打印功能也可以使用。

This is expected behavior, printf() will display text in a seperate screen. 这是预期的行为, printf()将在单独的屏幕中显示文本。 The alternative is maDrawText(int left, int top, const char* str); 替代方法是maDrawText(int left, int top, const char* str); which will allow you to draw the text in the paint area. 这样您就可以在绘制区域中绘制文本。

Your code could look like: 您的代码可能如下所示:

//Draw the Rectangle
maSetColor(0x0055ff);
maFillRect(10,10,100,100);

//Draw the text
maSetColor(0xffffff);
maDrawText(10,10,"Press zero or back to exit");

//Update the screen to reflect changes
maUpdateScreen(); 

Your first example works because you are calling the function before you update the screen and hence printf() will not draw on top of your current drawing. 您的第一个示例之所以有效,是因为您在更新屏幕之前正在调用该函数,因此printf()不会在当前图形之上绘制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM