Basic question why is my text not displaying

I am back to some PD dev and always seem to get stuck remembering what I am doing why is my text not staying on screen -

-- main.lua

-- Import the playdate library
import "CoreLibs/object"
import "CoreLibs/graphics"
import "CoreLibs/sprites"
import "CoreLibs/timer"

-- Define shorthand for commonly used libraries
local gfx =

-- Set up game variables
local message = "Title of Game"
local font = gfx.getSystemFont()
local screenWidth, screenHeight = playdate.display.getSize()

-- Create a rectangle sprite
local rectSprite =
local rectWidth, rectHeight = 50, 30
rectSprite:setSize(rectWidth, rectHeight)

-- Adjusted position
rectSprite:moveTo(rectWidth / 2, screenHeight / 2 + 50)

-- Set up the sprite's drawing function
function rectSprite:draw()
    gfx.fillRect(0, 0, rectWidth, rectHeight)

-- Update function, called once per frame
function playdate.update()
    -- Clear the screen

    gfx.drawTextAligned(message, screenWidth / 2, screenHeight / 4,

    -- Move the rectangle sprite across the screen
    local x, y = rectSprite:getPosition()
    x = x + 2              -- Move the sprite 2 pixels to the right each frame
    if x > screenWidth + rectWidth / 2 then
        x = -rectWidth / 2 -- Reset the position to the left edge once it goes off-screen
    rectSprite:moveTo(x, y)

    -- Update sprites

    -- Update timers

Not exactly sure where the issue is, my guess is that the gfx.sprite.update() also clears the screen (or rather dirty rects), but thats just a guess. If you replace the gfx.clear() with gfx.sprite.update(), the title is gonna show. Or keep the gfx.clear() and place the gfx.sprite.update() directly after it. Point is to have the gfx.sprite.update() on top of the playdate.update scope.

1 Like

Thanks moved the update to be after clear