Draw Text on screen

Discussion in 'Javascript/Plugin Support' started by Baka-chan, Oct 29, 2015.

  1. Baka-chan

    Baka-chan ☆*:.。. o(≧▽≦)o .。.:*☆ Veteran

    Messages:
    490
    Likes Received:
    145
    Location:
    Germany
    First Language:
    German
    I'd like to know how to display a text/variable on the screen. I made a time plugin and want to display the time on the screen but don't know how to get the text to be drawn on the screen.
     
    #1
  2. Jeremy Cannady

    Jeremy Cannady Coldfire Veteran

    Messages:
    449
    Likes Received:
    261
    Location:
    Texas
    First Language:
    English
    I would start by thinking about what other things draw text on the screen.

    I can think of the map name will appear, this is where I would start.

    You will have to make it apart of the Scene_Map so it can display.
     
    #2
  3. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,695
    Likes Received:
    922
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    To save yourself the trouble of all that backtracking, you'll need to create a sprite, in this case it seems Sprite_Base will do fine. Then, with that sprite you need to attach a new Bitmap to it, which is the part you can actually draw on. Once this is done, you need to, within the scene itself, call 

    this.addChild(mySprite)where mySprite is the variable you used when you created the sprite. Now that we got all the technicalities out of the way, feel free to draw on the sprite like so:

    mySprite.bitmap.drawText("text", x, y, maxWidth, lineHeight, "alignment")For the specifics of the drawText function, check the manual's documentation for Bitmap, it'll be there.
     
    #3
    Roguedeus likes this.

Share This Page