■gb.popup関数
Gamebuimo.hライブラリのgb.popup関数は、所定の期間、画面の下部にポップアップメッセージを表示します。
■使用例
gb.popup関数を使ったArduinoIDEのプログラム例は図1の通りです。
このプログラムを実行するとsetup関数中のgb.begin関数でGamebuinoオブジェクトを初期化し、gb.titleScreen関数で画面に「My first game」と表示します。
スタート画面でキーボードの「K」(GamebuinoのA)ボタンを押すと画面下にgb.popup関数により「Let's go!」と表示され、同時にgb.display.println関数により画面左上に「Hello world!」と表示され、その下にgb.frameCount変数の値がリアルタイムに更新されます。
参考に図1プログラムをHEXファイルに変換し、それをSimbuino4Webでエミュレートした結果を図2に示します。
//imports the SPI library (needed to communicate with Gamebuino's screen) #include <SPI.h> //imports the Gamebuino library #include <Gamebuino.h> //creates a Gamebuino object named gb Gamebuino gb; // the setup routine runs once when Gamebuino starts up void setup() { // initialize the Gamebuino object gb.begin(); //display the main menu: gb.titleScreen(F("My first game")); gb.popup(F("Let's go!"), 100); } // the loop routine runs over and over again forever void loop() { //updates the gamebuino (the display, the sound, the auto backlight... everything) //returns true when it's time to render a new frame (20 times/second) if (gb.update()) { //prints Hello World! on the screen gb.display.println(F("Hello World!")); //declare a variable named count of type integer : int count; //get the number of frames rendered and assign it to the "count" variable count = gb.frameCount; //prints the variable "count" gb.display.println(count); } }
図1:プログラム例
■構文
gb.popup(F( "Text")、duration)
■パラメータ
F("Text"):ポップアップされるテキスト(progmem char *)
duration:ポップアップが画面に表示される時間(フレーム数で表示)(byte)
(デフォルトでは毎秒20フレーム)
■戻り値
ありません
励みになりますのでよければクリック下さい(^o^)/