sprintf

Non-platform specific questions.

sprintf

Postby plinydogg » Thu Feb 23, 2006 7:31 pm

I'm trying to make an onscreen keyboard (to use instead of the SIP) and I think I need to use sprintf but can't figure out how to get it to work.

When the text actor that displays the name is created, I have the following pseudocode in create actor -> script editor:

stringvar = "";

Then, when you press the stylus down on a letter, say "q" for example, the following code is executed:

sprintf(stringvar, TextActor.text); //set stringvar = already typed letters
sprintf(TextActor.text, "q", stringvar); // concatenate stringvar and "q" and display the result in TextActor.text

When I add similar code to other letters, I can get TextActor to display the letter most recently typed, but cannot get it to add any letters (i.e., TextActor only displays one character...the most recently typed one).

I'm sure this is just me not knowing how to use sprintf.

Help is much appreciated!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Thu Feb 23, 2006 11:20 pm

Use strcpy to copy and strcat to concatenate strings:

strcpy(stringvar, TextActor.text);
strcat(TextActor.text, "q");
strcat(TextActor.text, stringvar);

Look sprintf sample here:
http://www.google.com/search?sourceid=n ... f+examples
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby plinydogg » Fri Feb 24, 2006 8:36 pm

Thanks for the help makslane but I'm still having difficulty. I think I'll try to take a different approach. How about this:

char TextArray[9];
int placeHolder = 0;

//on a mousedown event for the letter "q":

TextArray[placeHolder] = "q";
placeHolder++;

//Do the same for the other letters.

Question: how can I convert the char array (TextArray) into a string so that I can place it in TextNumber?

Thanks in advance!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score

Postby makslane » Sat Feb 25, 2006 12:46 am

If you need save a key sequence, look the thread:
http://game-editor.com/forum/viewtopic. ... ight=cheat
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby plinydogg » Sat Feb 25, 2006 2:58 pm

Just what needed! Thanks makslane!
plinydogg
 
Posts: 104
Joined: Thu Aug 25, 2005 8:34 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron