False INPUT text :)

Non-platform specific questions.

False INPUT text :)

Postby ingsan » Fri May 28, 2004 3:59 pm

Example : I would like to write ABCD on Screen. How can I do this ?
Simple :wink: First create 5 Text Actors : Helper, FirstLetter, SecondLetter, ThirdLetter and FourthLetter.

On Helper :

Add Event CREATE ACTOR, add Script and write :
    int KeyDown = 1;
Add Event KEYDOWN (any key), add Script and write :
    KeyDown ++;
On FirstLetter :

Add Event KEYDOWN (any key), add Script and write :
    char * Letter = GetKeyState();
    if ( Letter[KEY_a] == 1 && KeyDown == 2)
    {
    strcpy (FirstLetter.text , "A");
    EventDisable ("FirstLetter" , EVENTKEYDOWN); \\ to have the key pressed only once
    }
    else if ( Letter[Key_b] == 0 && KeyDown == 2)
    {
    strcpy (FirstLetter.text, "B");
    EventDisable ("FirstLetter" , EVENTKEYDOWN); \\ to have the key pressed only once

    }
    else if ( Letter[Key_c] == 0 && KeyDown == 2)
    {
    strcpy (FirstLetter.text, "C");
    EventDisable ("FirstLetter" , EVENTKEYDOWN); \\ to have the key pressed only once

    }
    else if ( Letter[Key_d] == 0 && KeyDown == 2)
    {
    strcpy (FirstLetter.text, "D");
    EventDisable ("FirstLetter" , EVENTKEYDOWN); \\ to have the key pressed only once

    }

What you do on SecondLetter, ThirdLetter or FourthLetter actors is the following :
Just Replace "FirstLetter" in the code above by the corresponding Actor's name e.g SecondLetter Actor > SecondLetter.text in Script.
Replace the following conditional value of integer variable KeyDown for each actor :
For SecondLetter > KeyDown == 3;
For ThirdLetter > KeyDown == 4;
For FourthLetter > KeyDown == 5;

Fine, now test it ! :)
User avatar
ingsan
 
Posts: 580
Joined: Mon Nov 17, 2003 4:02 pm
Location: Maurician LADY in FRANCE
Score: 6 Give a positive score

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest