Jump to content

Recommended Posts

Posted
Hello, I would like to know how to put a timer at the top of the screen, when we start our game.
Otherwise thank you very much for the previous answers, it helped me a lot !
Posted

Script.font = "" -- path "Font" -- use TrueType font file
Script.pos = Vec2(0,30) -- Vec2 "Position"
Script.size = 15 -- float "Size"
Script.color = Vec4(1,1,0,1) -- color "Color"
Script.offset = 20 -- int "Offset" -- make larger if numbers get cut off

function Script:Start()
    self.font = Font:Load(self.font,self.size)
    if self.font == nil then
        Debug:Error("Select a font")
    end
end

function Script:PostRender(context)

    defaultFont = context:GetFont()

    r = self.size + self.offset
    w = self.pos.x + window:GetWidth()/2 - self.offset
    h = self.pos.y

    --time factor
    time = Time:GetCurrent()/1000
    context:SetBlendMode(1)
    context:SetColor(self.color)
    context:SetFont(self.font)
    context:DrawText(Math:Round(time),w,h,r,r,Text.VCenter+Text.Center)
    context:SetFont(defaultFont)
end

Posted

Yeah, man. That's a little quirk in the system that I guess Josh never got around to straightening out.

Go to Scripts folder, and find "Main.lua". Open that and look for this:

    if gamemenu:Hidden() then
        
        --Update the app timing
        Time:Update()

        --Update the world
        world:Update()
        
    end

    --Render the world
    world:Render()


...then right before "world:Render()" add this line:

    gamemenu.gui:GetBase():Redraw()



 

fixbug.jpg

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...