Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Odd trouble drawing text  (Read 929 times)

0 Members and 1 Guest are viewing this topic.

Cerus

  • Newbie
  • *
  • Posts: 3
    • View Profile
Odd trouble drawing text
« on: December 13, 2011, 12:33:53 am »
Alrighty, so I can get my "tart new journey" and "[C]ontinue your journey" messages to appear in the first function of my source just fine:
This works perfectly...
Code: [Select]
int main(/*commandline arguments go here*/){
  Game.Display();
  Game.Clear();
  Game.EnableKeyRepeat(false);
  if(!Image[0].LoadFromFile("gfx/frame.png")){
    std::cout<<"Failed to load image!"<<std::endl;
  }
  //Set the image as a sprite...
  Sprite[0].SetImage(Image[0]);
  mtFont.LoadFromFile("gfx/FreeMono.ttf",12);
  menu_text1.SetText("[S]tart new journey");
  menu_text2.SetText("[C]ontinue your journey");
  menu_text1.SetFont(mtFont);
  menu_text2.SetFont(mtFont);
  menu_text1.SetSize(16);
  menu_text2.SetSize(16);
  menu_text1.Move(412,280);
  menu_text2.Move(412,294);
  Game.Clear();
  Game.Draw(Sprite[0]);
  Game.Draw(menu_text1);
  Game.Draw(menu_text2);
  Game.Display();

...yet when my second function (character naming and general 'newgame' stuff) begins, it fails to print the name-request, even though it still responds to events with...:
Code: [Select]
int game_start(){
  Game.Display();
  if(!Image[0].LoadFromFile("gfx/frame.png")){
    std::cout<<"Failed to load image!"<<std::endl;
  }
  //Set the image as a sprite...
  Sprite[0].SetImage(Image[0]);
  mtFont.LoadFromFile("gfx/FreeMono.ttf",12);
  menu_text1.SetText("By what name shalt");
  menu_text2.SetText("thee be known?");
  menu_text1.SetFont(mtFont);
  menu_text2.SetFont(mtFont);
  menu_text1.SetSize(16);
  menu_text2.SetSize(16);
  menu_text1.Move(412,280);
  menu_text2.Move(412,294);
  Game.Clear();
  Game.Draw(Sprite[0]);
  Game.Draw(menu_text1);
  Game.Draw(menu_text2);
  Game.Display();

...and yes, the second function is called.  All I get in return is the blank 'frame' image also used in the first function.  What am I doing wrong?  I feel like a complete fool.  @_@;

EDIT:  Alrighty, so...  I changed MenuText1 and MenuText2 into a single array known as menu_text.  Setting the code to display this array has kept what already worked working, but curiously, the second function was only willing to display
  • and [1] in the first function, then [3] and [4] in the second.  It does, at least, display now, which is a vast improvement, but I'm thinking I may need to (somehow) clear the memory from menu_text
  • through [2] which were used by the first function (since I added an option to view credits, I had to use [2] as well, if you were confused).  Apparently, I can't reuse those menu_texts just yet... @_@;  I'm sure I'll find a fix for that soon enough!  :)