• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Sphere - Pokemon Style Text.

Waudby

Guest
  • 0
    Posts
    Hi Guys.

    I've decided to do a small tutorial about how to make a similar style text system in Sphere as the one in the official Pokémon games.

    It's a simpler one of the system I am using for Pokémon Odyssey.

    Everything is commented into the code, so it should be easily read from the code here;

    Start a new project and work through this code.

    It will show three lines of text, using letter by letter and with the ability to use the right arrow key to speed up the text.

    Read through the comments and you can make a system like this or better easily.

    Code:
    function game()
    {
    Text("Hello World. This is my text box.");
    Text("It is written to show how to make character by character text.");
    Text("Hold the right key to speed up the text.");
    }
    
    function Text(text)
    {
    
    //Load all the fonts and window styles here. Use your current ones from the script you sent me.
    var font = GetSystemFont();
    var windowStyle = GetSystemWindowStyle()
    
    
    //Predefine all the positioning stuff so that you can easily change everything at once.
    var x = 20;
    var y = 160;
    var height = 10
    var width = GetScreenWidth() - 50;
    
    //this variable is used for the character by character bit.
    var OutText = "";
    
    //Used to define how fast or slow the text is.
    //the lower the slower.
    var speed = 1;
    
    var OldSpeed = speed;
    
    if(IsMapEngineRunning())
    {
    RenderMap()
    }
    
    //Get time is used to make sure that the text goes by at the same speed for a set time.
    var start_time = GetTime();
    
    for (var s = 0; s <= text.length; s++)
    {
      ClearKeyQueue();
      
      if(GetTime() > start_time + speed)
      {
        //Refresh the start time variable so it has a new time so the script keeps going.
        start_time = GetTime();
        
        //Rvert the speed back to the old speed.
        speed = OldSpeed;
        
        //draw the window
        windowStyle.drawWindow(x, y, width, height);
        
        // text.slice is a string method which slices the string at a set point. Starting at the first parameter and ending at the last
        //In this case we need it to change as time goes by so we use 's' because it gets incremented.
        OutText = text.slice(0, s);
        
        //draw the text.
        font.drawTextBox(15,153,width + 10, height + 20, 0, OutText);
            
        if(IsKeyPressed(KEY_RIGHT))
        {
        speed -= 1
        } 
        
        Wait(speed * 100);
      }
      FlipScreen()
    }
    
    ClearKeyQueue();
    while(!IsKeyPressed(KEY_Z) && OutText.length == text.length);
    }
    
    function ClearKeyQueue()
    {
      while (AreKeysLeft()) GetKey();
    }
    
    function Wait(milliseconds)
    {
      var start = GetTime();
      while (start + milliseconds > GetTime())
      { 
      if(IsMapEngineRunning())
      {
            UpdateMapEngine();
            RenderMap();
            }
      }
    }
    Any questions or problems let me know.

    I now have a better version of this available to download.

    It has test maps etc

    GET IT HERE: https://rapidshare.com/files/115087023/TextTechDemo.rar
     
    Last edited:
    Back
    Top