Time for action — creating the title screen

Our title screen will be composed of a nice single-colored background, the text Balls Out!, and two text buttons to Play and Exit the game:

  1. Create the CreateTitleScreen method inside the game class.
    Method CreateTitleScreen:Int ()
    
  2. Create a new box object, assign it to the title layer, and set the color to a nice blue.
    Local box:ftObject = eng.CreateBox(cw-20,ch-20,cw/2,ch/2)
    box.SetLayer(layerTitle)
    box.SetColor(0,0,255)
    
  3. Now, create a text object that is also assigned to the title layer. Scale it to the factor 3.
    Local tx1:ftObject = eng.CreateText(font1,"Balls Out!",cw/2,ch/5,1)
    tx1.SetLayer(layerTitle)
    tx1.SetScale(3.0)
    
  4. To start and exit the game, we need two text buttons, both scaled to factor 1.5 and assigned to the title layer.
    Local b1:ftObject = CreateTextButton(font1, "Play", cw/2,ch/5*3, btnPlay, layerTitle)
    b1.SetScale(1.5)
    Local b3:ftObject = CreateTextButton(font1, "Exit", cw/2,ch/5*4, btnExit, layerTitle)
    b3.SetScale(1.5)
    
  5. Close the method.
    Return 0
    End
    

What just happened?

With this method, we will be able to create the title screen in one call. It's also a place that you can easily identify to add and change the screen in its total appearance.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.35.194