Discord
Login
Community
DARK THEME

Text with Quick engine

could something like this work control_help = Quick.addText("hello",0,150,300,300)

Hello, so if you want to have text(Or any kind of GUI) up on the screen, while using Quick it's better to just use the normal microStudio graphics lib like this:

draw = function()
 Quick.draw()
  screen.drawText("hello",0,150,300,300) // or simply create a seperate UI function and put everything you want in there :)
 end

ok tysm

If you want to obtain the effect of an inscription over a moving object, use the "Quick.addText" function (e.g. over a player with HP).

If you want to get a string that is part of the GUI, you need to slightly modify the engine.

here is an example of how to do it. Add one function to the engine


Quick.addTextGUI = function(text,x,y,height=10)
  local t = object
    object_type = "textGUI"
    text = text
    x = x
    y = y
    display = 1
    height = height
    font = "BitCell"
    color = "rgb(255,255,255)"
  end
  
  objects.push(t)
  return t
end

Modify the drawing function - the added fragment is selected.

Quick.draw = function()
  local time = system.time()
  if last_time then
    local dt = time-last_time
    if dt<100 and dt>0 then
      if tick<60 then
        avg_dt = max(1,avg_dt*.9+dt*.1)
      else
        avg_dt = max(1,avg_dt*.999+dt*.001)
      end
      fps = max(60,1000/avg_dt)
    end
  end
  
  last_time = time
  
  if not position_updated then
    positionUpdate()
  end
  
  position_updated = 0
  
  if background then
    screen.fillRect(0,0,screen.width,screen.height,background)
  end
  local angle = random.next()*PI*2
  local cx = camera.x+camera.shake*sin(angle)
  local cy = camera.y+camera.shake*cos(angle)
  local zoom = camera.zoom
  for o in objects
    if not o.display then continue end
    if o.object_type == "sprite" then
      if o.hflip then screen.setDrawScale(-1,1) end
      if o.vflip then screen.setDrawScale(1,-1) end
      if o.hflip and o.vflip then screen.setDrawScale(-1,-1) end
      if o.rotation then
        screen.setDrawRotation(o.rotation)
        screen.drawSprite(o.name,(o.x-cx)*zoom,(o.y-cy)*zoom,o.width*zoom,o.height*zoom)
        screen.setDrawRotation(0)
      else
        screen.drawSprite(o.name,(o.x-cx)*zoom,(o.y-cy)*zoom,o.width*zoom,o.height*zoom)
      end
      screen.setDrawScale(1,1)
    elsif o.object_type == "map" then
      screen.drawMap(o.map,(o.x-cx)*zoom,(o.y-cy)*zoom,o.width*zoom,o.height*zoom)
    elsif o.object_type == "text" then
      screen.drawText(o.text,(o.x-cx)*zoom,(o.y-cy)*zoom,o.height*zoom,o.color)
// ---------------------------------------------------------------------
      elsif o.object_type == "textGUI" then
      screen.drawText(o.text,o.x*zoom,o.y*zoom,o.height*zoom,o.color)
//-----------------------------------------------------------------------
    end
  end
  
  return
end

Use

  fps = Quick.addTextGUI("fps",-100,20,15)

The text will be stationary and its position is relative to the center of the screen.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community