Mon Oct 10, 2016 6:03 pm
int Level = 3;
if(gb.buttons.pressed(BTN_A))
gb.popup(F("You beat the level " + Level), 20);
in expansion of macro 'F'
Tue Oct 11, 2016 2:08 am
Tue Oct 11, 2016 11:50 am
Tue Oct 11, 2016 11:54 am
Duhjoker wrote:I can't "I" am going to say this,lol. But you should really check out the reference for the functions found here....
http://gamebuino.com/wiki/index.php?title=Reference
where you are trying to add an argument for the level is actually for a duration of the pop-up. Instead, it would be easier to write a popup for each level and then have it called once per level.
Tue Oct 11, 2016 12:19 pm
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
String myPopupText;
byte myPopupTimeLeft;
void setup(){
gb.begin();
gb.titleScreen(F("Custom Popup"));
}
void loop(){
if(gb.update()){ //update everything
gb.display.println(F("Custom popups"));
gb.display.println(gb.frameCount);
if(gb.buttons.pressed(BTN_A)){
myPopup(String("Frames = ") + gb.frameCount, 40);
}
myPopupUpdate();
if(gb.buttons.pressed(BTN_C)){
gb.titleScreen(F("Custom Popup"));
}
}
}
void myPopup(String text, byte time){
myPopupText = text;
myPopupTimeLeft = time;
}
void myPopupUpdate(){
if (myPopupTimeLeft){
gb.display.fontSize = 1;
gb.display.setColor(WHITE);
gb.display.fillRoundRect(0,LCDHEIGHT-gb.display.fontHeight-3,84,gb.display.fontHeight+3,3);
gb.display.setColor(BLACK);
gb.display.drawRoundRect(0,LCDHEIGHT-gb.display.fontHeight-3,84,gb.display.fontHeight+3,3);
gb.display.cursorX = 4;
gb.display.cursorY = LCDHEIGHT-gb.display.fontHeight-1;
gb.display.print(myPopupText);
myPopupTimeLeft--;
}
}
Thu Oct 13, 2016 12:26 am